3

I am trying to rename a site collection, using scripts something like this:

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

I used stsadm:

stsadm -o renamesite -oldurl http://test.matt.com -newurl https://test.matt.com

But does not work and I keep getting this error.

Exception calling "Rename" with "1" argument(s): "Could not rename this site collection. The URL specified is already in use."

I did a test on another web application using the scripts above, and that worked just fine. Not in this one though.

This one has three zone:

  • Default
  • Extranet
  • Internet

I got the scripts from these urls:

What could be the problem?

Update: I am updating a site collection host header to a site collection host header.

Update 2 SSL is enabled at Web Application level. There are 500+ site collections

  • R u trying to rename path based site collection to host name sitecollection? – Waqas Sarwar MVP Dec 20 '17 at 15:08
  • I am trying to rename from host name site collection to host name site collection. – Burre Ifort Dec 20 '17 at 15:25
  • Ur code is confusing? Are you trying to change the http to https or something from oldurl.com to newurl.com ? Can you run get-spite against new url and see if it returns anything. – Waqas Sarwar MVP Dec 20 '17 at 15:43
  • trying to change http to https – Burre Ifort Dec 20 '17 at 16:07
  • IS SSL configured at Web Application level? how many site collections in the Web Application? – Waqas Sarwar MVP Dec 20 '17 at 17:47
1

Try to do an backup-spsite and then remove the site, and finally restore it back.

Use this code. It has worked for me. Modify the url parameters as needed and the path of the file.

Backup-SPSite https://currentsite -Path D:\backupsite.bak
Remove-SPSite –Identity https://currentsite –Confirm:$False 
Restore-SPSite https://newsitesiteurl -Path D:\backupsite.bak -HostHeaderWebApplication https://webapphostnameurl.com
1

Can you check whether any site with same name is listed in SPDeletedSite? Use PowerShell script to see the list of deleted site

==>Get-SPDeletedSite

If you can see the site with the same name,copy the identity of site and remove it using below powershell command

Remove-SPDeletedSite –Identity 9d0ed313-0353-4cec-817a-a491a8c5fc26
  • 1
    I have used Get-SPDeletedSite and there were no sites with this name – Burre Ifort Dec 20 '17 at 14:25

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.