Question

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.

Was it helpful?

Solution 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.

OTHER TIPS

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.

  • 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.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top