vendredi 1 mars 2013

Modify Site Collection URL SharePoint 2010

In order to rename a Site collection in SharePoint 2010 you need to backup the site first and restore it on an new Site collection.
To do that you can use the following PowerShell :
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
#Get the Source Site Collection URL
$sourceURL = Read-Host “Enter the Source Site Collection URL:”
#Get the Target Site Collection URL
$targetURL = Read-Host “Enter the Destination Site Collection URL”
#Location for the backup file 
$backupPath = Read-Host “Enter the Backup File name & location (E.g. c:\temp\Source.bak):”
#Backup the source site collection
Backup-SPSite $sourceURL -Path $backupPath -force
#Delete source Site Collection 
Remove-SPSite -Identity $sourceURL -Confirm:$false
#Restore Site Collection to new URL
Restore-SPSite $targetURL -Path $backupPath -Confirm:$false
#Remove backup files
Remove-Item $backupPath
write-host "Process Completed!"