Tuesday, 19 November 2013

move site collection from one web application to another web application using powershell

Share it Please
Example Script:-


#Get the from Site Collection URL
$fromURL = "http://Abcd:5000/sites/Fromsite"
#Get the to Site Collection URL 
$toURL = "http://sfs01:4000/sites/Rsite3/"

#Location to the backup file directory to store Site Collection backup files
$backupPath = "C:\\SiteBK.bak"

#Backing up Site Collection prior to moving
Write-Host "Backing Up Site Collection…."
Backup-SPSite $fromURL -Path C:\SiteBK.bak -force

#Removing Site Collection from old web application path
Write-Host "Removing Site Collection from old managed path location…"
Remove-SPSite -Identity $fromURL -Confirm:$false

#Restoring Site Collection to new Managed Path
Write-Host "Restoring Site Collection to new managed path location…"
Restore-SPSite -Identity $toURL -Path c:\SiteBK.bak -Confirm:$false

#Remove backup files from the backup dirctory
Remove-Item c:\SiteBK.bak

No comments:

Post a Comment

Followers

Follow The Author