# Rename sitecollection

Im trying to rename a site collection by changing the url by using this PowerShell

$site = get-spsite -identity http://xxx:9000/sites/SCOne$site.Rename("http://xxx:9000/sites/SCOneNew")


I got this message

Exception calling "Rename" with "1" argument(s): "Cannot rename a site collection with recycled items. Empty the site recycle bin of site collectio

The recycle bin is empty now but I still can't rename and I get the same message.

I have tried this PowerShell to get count of items in recycle bin

$site = get-spsite http://xxx:9000/sites/SCOne Write-Host$site.RecycleBin.Count.ToString();


but it says

you cannot call a method on a null-valued expression

• In your second script, you are using the new URL. You have not successfully moved it yest so you need to use the old URL http://xxx:9000/sites/SCOne. Also, the .ToString() is not necessary – Robert Lindgren Nov 7 '14 at 8:40
• i just wrote wrong, now its edited – Gästa Nov 7 '14 at 8:54
• Please ensure you are using your FARM ADMINISTRATOR account to perform this action. – Manivannan Nagarajan Jun 13 '16 at 9:50

Maybe you're site is still listed as a SPDeletedSite?

You may already have used this site name before and deleted it. Check by running the following script:

>Get-SPDeletedSite


You'll see the site (or sites) listed, like this:

WebApplicationId   : 009c1289-392b-43a6-8222-146117074738
DatabaseId         : 88efc46f-5a2b-4171-81cb-7577da65bac3
SiteSubscriptionId : 00000000-0000-0000-0000-000000000000
SiteId             : 86d69f7e-3a9e-4f65-8eba-550d77f93a18
Path               : /sites/collaboration
Scheme             : Http
Url                : http://portal/sites/collaboration
DeletionTime       : 2014-02-21 11:14:18

WebApplicationId   : c73bb367-d329-4ef2-aef7-323ce207d2a9
DatabaseId         : aeb2d6ab-9f9b-493f-aefc-797d4b591f43
SiteSubscriptionId : 00000000-0000-0000-0000-000000000000
SiteId             : 9d0ed313-0353-4cec-817a-a491a8c5fc26
Path               : /
Scheme             : Http
Url                : http://portal/
DeletionTime       : 2014-02-19 15:27:37


Copy the SiteId and run

Remove-SPDeletedSite –Identity 9d0ed313-0353-4cec-817a-a491a8c5fc26


That way you won't have trouble renaming the site if needed.

• What!! i havnt even deleted the site !! The site still exists. – Gästa Nov 7 '14 at 9:27
• @Gästa, please keep a polite tone. We are trying to solve your problems, so try to treat us with respect – Robert Lindgren Nov 7 '14 at 9:40
• Sorry if it sounds unpolite. i mean just i was surprised Förvånad – Gästa Nov 7 '14 at 9:48
• @Gästa No worries! What I mean is that the site with the name you're trying to rename to have already been used previously, and deleted before you came to the table. Just run the script Get-SPDeletedSite and see if this is an issue or not. It's just a sanity check minimizing the causes of errors you may have. :-) – Benny Skogberg Nov 7 '14 at 9:50
• i checked is, there is no deleted site with this name. The problem is that i cannot remove the items by powershell. when i delete items manualy from Recycle bin page, they dont be removed permanently i think they still exist somewhere. so the problem is in the deletion of the items in recycle bin – Gästa Nov 7 '14 at 10:22

I had the same issue and here is what worked for me:

1) Empty the Site Collection Recycle Bin

2) On the left hand side of the Site Collection Recycle Bin page, you will see a link that says "Deleted from end user Recycle Bin"

3) Go to that link and empty the end user recycle bin, as well.

I was then able to rename the site.