4

On SharePoint 2013 I'm trying to delete a site collection programmatically and send it to the Recycle Bin. Through the interface is no problem, it goes straight to the Recycle Bin, but when it comes to PowerShell,

  • Remove-SPSite doesn't have a -Recycle parameter, so the site collection doesn't go to the Recycle Bin.
  • Remove-SPWeb has this parameter, but this cmdlet doesn't let me use it because Cannot put top-level site into Recycle Bin.

What am I doing wrong? Is there any way to achieve this?

Thanks.

Edit: I forgot to say that a C# solution is also valid, even preferable.

  • 1
    It by default places in the Recycle Bin. No need to specify any parameters. To delete from recycle bin you can use Remove-SPDeletedSite – Amal Hashim Nov 21 '14 at 15:51
  • @AmalHashim I'm not so sure about this. When I Remove-SPSite it doesn't appear on the Recycle Bin with Get-SPDeletedSite. – Armaggedon Nov 21 '14 at 16:02
2

This has more to do with the differences between sites and site collections. Site Collections do not go the the site collection recycle bin. That would be impossible since you cannot put a site into its own recycle bin. There is what is known as "Deleted sites", if that is what you are looking for, please see here.

2

Well, I didn't notice a parameter which was the key to achieve this: -GradualDelete. So, knowing this,

Remove-SPSite -Identity "https://host/site" -GradualDelete

does the trick and the site appears at Get-SPDeletedSite.

Thanks everyone for your time and answers.

0
  • Remove-SPSite will delete the site collection in put in Central Admin Recyebin Which is accessible via powershell. All deleted Sites will sit their for 30 days and you can recover it.

To get the deleted Sit you have to run the Get-Spdeletedsite, if you know the site collection name then you have give it as a parameter. i.e Get-SPDeletedSite '/Site/cat*'

To recover it use the [Restore-SPDeletedSite][2]

  • Remove-SPWeb, you cannot delete the top level site because if you delete it then recycling also effect...Top level site is import for all the activities under that site.
  • 1
    That's what I thought, but is not happening, the site collection doesn't appear with Get-SPDeletedSite. The Recycle Bin Status of this Web Application is on, so I'm not sure what could be happening. – Armaggedon Nov 21 '14 at 16:15
  • what version of sharepoint you are using? did you run the get-spdeletedsite 'site collection" if you deleting the root then value should be "/" but you deleted 2nd level then it should be "sites/name" managedpath and name – Waqas Sarwar MVP Nov 21 '14 at 16:18
  • Version 15.0.4667.1000, November 2014. The site collection was at host/site, but nothing related to it appears on the list of Get-SPDeletedSite. – Armaggedon Nov 21 '14 at 16:28
  • is it Host Name site collection? can you get the Site ID before it delete then check it...just make sure you are on right farm from where you deleting and where you are checking... can you try to delete it via Central admin and then check it? – Waqas Sarwar MVP Nov 21 '14 at 16:32
  • Yes, via Central Admin it goes straight to the Recycle Bin and can be restored without any problem, but otherwise the Bin appears empty. The same happens over two different SharePoint deployments I have. – Armaggedon Nov 24 '14 at 10:39

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.