0

Does know if this PowerShell works just to rename a path based site collection to a differently named path based site collection?

$site = Get-SPSite http://portal.contoso.com/sites/foo 
$uri = New-Object System.Uri("http://portal.contoso.com/sites/fooNew") 
$site.Rename($uri)

I tried it on a test site collection and it seemed to work OK, but I was just wondering if anyone has tried this on a real site collection and has encountered issues.

2

Yes it should work at site collection

$site = Get-SPSite http://portal.contoso.com/sites/foo 
$uri = New-Object System.Uri("http://foo.contoso.com") 
$site.Rename($uri)

To get 100% success I have to force the Content Database to refresh its site map with this:

((Get-SPSite http://foo.contoso.com).contentdatabase).RefreshSitesInConfigurationDatabase

Then perform IISRESET

Note:

Despite you have tried this script on subsite and I told you it should work at site collection with the same result , but to be comfortable with this script at real site collection , I advise you to try it first at a test site collection in the same production farm and check the result , then apply it to the real Site collection based on this result.

For more details check the detailed story at How to Rename SharePoint 2013 Site Collections Without Prayer or Sobbing

  • I tried this again with a site collection that has a space in its name and it did not work - worse it seemed to half work and now it seems to be corrupted. $site = Get-SPSite "spdevsp01/sites/Rename SC" $uri = New-Object System.Uri("spdevsp01/sites/Newname SC") $site.Rename($uri) – Rob P Jan 11 '17 at 21:42
2

I did this in my environment many times, Initially this command is for moving Path based site collection to HNSC but eventually it is working for path to path based site collection.

Only drawback of this method is you have to reset IIS which cause outage for the customer. there are 3 methods to achieve this.

  1. Using the Backup And Restore Method
  2. Use the Copy-SPSite
  3. Using the Rename method of SPSite.

You can read this article for complete info.SharePoint 2016 Rename Site Collection URL Best Practice

  • I tried this again with a site collection that has a space in its name and it did not work - worse it seemed to half work and now it seems to be corrupted. $site = Get-SPSite "spdevsp01/sites/Rename SC" $uri = New-Object System.Uri("spdevsp01/sites/Newname SC") $site.Rename($uri) – Rob P Jan 11 '17 at 21:41
  • What happen, any error you get? you tried the site.rename method? – Waqas Sarwar MVP Jan 11 '17 at 21:45
  • I did not get an error. I was able to use stsadm deletecontentdb and addcontentdb to get it working again – Rob P Jan 12 '17 at 0:26
  • That's good, as per my personal experience I always prefer backup site collection and restore it on different URL. All the time works for me – Waqas Sarwar MVP Jan 12 '17 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.