Recently I got question from one of the interview how to change the Site collection URL.
Answer :
By default there is no way to change site collection URL in SharePoint(not sub-site) so after search in google i found the url and below step.
Read more: http://www.sharepointdiary.com/2012/07/how-to-change-site-collection-url.html
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):”
Try
{
#Set the Error Action
$ErrorActionPreference = "Stop"
Write-Host "Backing up the Source Site Collection..."-ForegroundColor DarkGreen
Backup-SPSite $sourceURL -Path $backupPath -force
Write-Host "Backup Completed!`n"
#Delete source Site Collection
Write-Host "Deleting the Source Site Collection..."
Remove-SPSite -Identity $sourceURL -Confirm:$false
Write-Host "Source Site Deleted!`n"
#Restore Site Collection to new URL
Write-Host "Restoring to Target Site Collection..."
Restore-SPSite $targetURL -Path $backupPath -Confirm:$false
Write-Host "Site Restored to Target!`n"
#Remove backup files
Remove-Item $backupPath
}
catch
{
Write-Host "Operation Failed. Find the Error Message below:" -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor Red
}
finally
{
#Reset the Error Action to Default
$ErrorActionPreference = "Continue"
}
write-host "Process Completed!"
I Love PowerShell! The above method is also applicable when you want to change the Managed Path of your site collection (both SharePoint 2007 & SharePoint 2010).
Answer :
By default there is no way to change site collection URL in SharePoint(not sub-site) so after search in google i found the url and below step.
Read more: http://www.sharepointdiary.com/2012/07/how-to-change-site-collection-url.html
How to Change Site Collection URL in SharePoint?
To change the site collection's URL, There is no out-of-the-box user interface or direct ways. So, after making sure the destination URL's managed path is already in place and verifying the target site collection URL doesn't exist, I do this three step manual process.- Backup the Source Site collection
- Delete the Source Site collection (Yes, its must! we've to delete the site collection before restoring it. Otherwise you will end up in No content databases are available for this operation GUID conflict issue.)
- Restore the Backup with the target URL
stsadm -o backup -url http://sharepoint.crescent.com/sites/source -overwrite -filename source.bak
stsadm -o deletesite -url http://sharepoint.crescent.com/sites/source
stsadm -o restore -url http://sharepoint.crescent.com/sites/destination -filename source.bak
Change SharePoint site collection URL using 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):”
Try
{
#Set the Error Action
$ErrorActionPreference = "Stop"
Write-Host "Backing up the Source Site Collection..."-ForegroundColor DarkGreen
Backup-SPSite $sourceURL -Path $backupPath -force
Write-Host "Backup Completed!`n"
#Delete source Site Collection
Write-Host "Deleting the Source Site Collection..."
Remove-SPSite -Identity $sourceURL -Confirm:$false
Write-Host "Source Site Deleted!`n"
#Restore Site Collection to new URL
Write-Host "Restoring to Target Site Collection..."
Restore-SPSite $targetURL -Path $backupPath -Confirm:$false
Write-Host "Site Restored to Target!`n"
#Remove backup files
Remove-Item $backupPath
}
catch
{
Write-Host "Operation Failed. Find the Error Message below:" -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor Red
}
finally
{
#Reset the Error Action to Default
$ErrorActionPreference = "Continue"
}
write-host "Process Completed!"