Overview:
In many cases, end users keep creating sub sites and uploading content to an existing site , and the system admin discover that the Content Database size reached the recommended values of Microsoft, in such cases, admin need to take corrective actions to keep the farm running.
One of the options is to promote some sub-sites to their own site collections and split the site collections across different content Databases.
The script below perform the basic operations to promote a site to a site collection. The script is just a guide to help you in the process, use it at your own risk, and after proper testing.
Script:
#Update the values for the 4 variables below
$oldSPwebUrl="http://server/exporttest" $exportPath="C:\export\export.cmp" $Owner="domain\administrator" $Descr="Test Description"
#Do not change after this line
$oldSPWeb = Get-SPWeb $oldSPwebUrl
$siteRelativeURL = $OldSPWeb.ServerRelativeUrl.trim('/')
$SPWebApp = $oldSPWeb.Site.WebApplication
#Export site
Write-Host "Exporting Site :"$oldSPwebUrl
Export-SPWeb $oldSPwebUrl -Path $exportPath -IncludeUserSecurity -IncludeVersions All -Force
#Change current site URL Write-Host "Changing Site URL to:"$siteRelativeURL"_org" Get-SPWeb $oldSPwebUrl | Set-SPWeb -RelativeUrl $siteRelativeURL"_org" #Create managed Path(Explicit) Write-Host "Creating managed path:"$siteRelativeURL New-SPManagedPath -RelativeURL $siteRelativeURL -WebApplication $SPWebApp -Explicit #Create new site Write-Host "Creating site collection:"$oldSPwebUrl $newSPSite = New-SPsite -Url $oldSPwebUrl -OwnerAlias $Owner -Template "STS#0" -Description $Descr $newSPWeb = $newSPSite.RootWeb #Import content Write-Host "Importing content to site collection:"$oldSPwebUrl Import-SPweb $newSPWeb -Path $exportPath Write-Host "Completed."
Notes:
1- The script does not delete the original site, after completing your testing, you can delete it manually or through PowerShell.
Limitations:
1- Alerts are not migrated,
2- Workflows are not migrated.
3- Works only on sites on root site collection under first level, it needs to be altered if sites are in different level, or to be moved to different URL.
4- Navigation settings(top/left) might get affected by the promotion, so, you need to manually check it and update as needed.
4- Navigation settings(top/left) might get affected by the promotion, so, you need to manually check it and update as needed.
No comments:
Post a Comment