Move that SharePoint SubSite into its own site collection.

So it seemed like a good idea at the time, all of the sites on the root site collection but now you are beginning to regret that the content database is getting a little on the large side and managing the security is getting to be a pain.

So how do you move this subsite into it’s own site collection?

You can go ahead and pick up a migration tool from ShareGate of Metalogix both very good tools but you only want to move the site, feel free to grab this PowerShell script that will do it for you.

All you need to do is change the “script options” to reflect your needs and you should be away.

Remember that you use this script at your own risk and  you should backup ad test everything before you commit to running it.

The script can run the commands or build a script for you to use at a later date, your choice just look at the $debug  & $execute  options.

Download file : ConvertSubSiteToSiteCollection as a text file

 

Finding that SharePoint Correlation ID

So you have an issue in SharePoint and a screenshot form a user in a production environment.

You have asked the production support team to put SharePoint log viewer onto the server and they have submitted the request to the change group and will get back to you in a couple of days and in the mean time your user is going up the wall.

So you have the Correlation ID and need to find out what is going on, you can use the Get-SPEventLog cmdlet and filter things but remembering the syntax is more that you can do after the day you are having.

Feel free to grab this script that you can put on the server pass the Correlation ID to it along with some other things and you will have the information you are looking for to help you get to the bottom of the problem.

Download file: GetSPError as a text file

Examples of usage:

GetSPError.ps1 -GUIDToFind 00000000-0000-0000-0000-000000000000 -NumberOfMinutes 10
This will only look in the last 10 minutes of the log.

GetSPError.ps1 -GUIDToFind 00000000-0000-0000-0000-000000000000 -NumberOfMinutes 0
This will look at all of the the log.

GetSPError.ps1 -GUIDToFind 00000000-0000-0000-0000-000000000000 -NumberOfMinutes 10 -FileName error.txt
This will only look in the last 10 minutes of the log and send the output to the error.txt file.

GetSPError.ps1 -GUIDToFind 00000000-0000-0000-0000-000000000000 -NumberOfMinutes 0 -FileName error.txt
This will look at all of the the log and send the output to the error.txt file.

Get-Help GetSPError.ps1
This will list the help for this file.

PowerShell script template

This file is the Powershell template file that I use when creating PowerShell scripts.

The code below is a functioning PowerShell script for you to build on, it has the syntax for the Get-Help cmdlet to function correctly and takes three parameters some mandatory some not, it also outputs to the screen the script execution start & end time along with elapsed time.

Download file : Powershell Template as a text file.

  1. <#
  2. .SYNOPSIS
  3. This script will ....
  4.  
  5. .DESCRIPTION
  6. A Script description & version history.
  7.  
  8.  
  9. --------------------------------------------------------
  10. History
  11. Version number | Data | Comment
  12. 1.00 | <date> | Initial script.
  13. --------------------------------------------------------
  14.  
  15. .LINK
  16. http://www.glossover.co.uk/archives/322
  17.  
  18. .EXAMPLE
  19. <scriptName> -Param1 value -Param2 value
  20. <scriptName> -Param1 value -Param2 value -Param3 (optional) value
  21.  
  22. #>
  23.  
  24.  
  25. Param (
  26. [Parameter(Mandatory=$true, HelpMessage="Please enter a string value")]
  27. [alias("Param1")]
  28. [ValidateNotNull()]
  29. #String value.
  30. [string]$stringValue,
  31.  
  32. [Parameter(Mandatory=$true, HelpMessage="Please enter a numeric value.")]
  33. [alias("Param2")]
  34. [ValidateNotNull()]
  35. #Number value.
  36. [int]$intValue,
  37.  
  38. [Parameter(Mandatory=$false, HelpMessage="Please enter a string value (Optional).")]
  39. [alias("Param3")]
  40. [ValidateNotNull()]
  41. #Optional string value.
  42. [string]$optionalStringValue
  43.  
  44. )
  45.  
  46. $startTime = Get-Date
  47. Write-Host "Start time : $startTime"
  48.  
  49.  
  50. #Passed values
  51. Write-Host "Param1 : " $stringValue
  52. Write-Host "Param2 : " $intValue
  53. Write-Host "Param3 (optional) : " $optionalStringValue
  54.  
  55.  
  56. $endTime = Get-Date
  57. Write-Host "Script execution time : $( New-TimeSpan $startTime $endTime)."
  58. Write-Host "End time : $endTime"