Koen Vosters

There is always a point in sharing.

Deleting and restoring a site collection.

Issues pop up when you delete a site collection and then want to restore it from a backup. When you delete a site collection it is not completely deleted from the content database. If at that point you try to restore it from a backup it will fail. The solution to this is quite easy, but when I saw the posts out there who propse database modifications (which is not supported by the way) I decided to put up a post.

The correct way to do it is the following:

Get-SPDeletedSite

This will give you an overview of the sites that are deleted but still  “out there”.

The property we are interested in is the site id.

Now create the content database object:

$webapp = Get-SPWebApplication https://myawesomesite.koentoso.com

$cdb = $webapp.ContentDatabases.Item(0)

Then we will force the delete of the site with the id from the previous command Get-SPDeletedSite.

$cdb.ForceDeleteSite(“8da556e0-264f-483b-a2b0-3fb1f8e33573”,$false,$false)

Now you should be able to restore your site collections without any issues.