Deleting an undelete-able site collection

 Oct 08, 2015

If you create site collections using a batch script, and if one of those was unreachable. As the site creation process may have failed thus any resources will not be provisioned correctly.

File provisioning is one of the last operations that is performed during site creation, you may then get a HTTP400 response (bad request) accessing the site home page.

The symptoms of things not being okay will be fairly self-evident.

The Central Administration displays the site in the sites list, but without any reference to the Content Database where it should have been created. There is no way to remove it using the web interface as the pages that display information about the site have no content.

This can be fixed using a PowerShell script.

Get-SPSite will return a valid object, however Remove-SPSite will fail and say “Unknown SPRequest error.occurred”.
A quick solution, is to use “force delete” where the site cannot be deleted.
Use a not-so-well-known operation on the Content Database object:
(See here)

The PowerShell code is very simple:

$site = Get-SPSite http://siteurl $siteId = $site.Id $siteDatabase = $site.ContentDatabase $siteDatabase.ForceDeleteSite($siteId, $false, $false)

The bad site collection can thus be removed sucessfully!

How do your Excel skills stack up?   

Test Now  

About the Author:

Steve Wiggins  

Steve is a highly experienced technical trainer with over 10 years of specialisation in Software Application Development, Project Management, VBA Solutions and Desktop Applications training. His practical experience in .NET programming, advanced solution development and project management enables him to train clients at all levels of seniority and experience. Steve also currently manages the IT infrastructure for New Horizons of Brisbane, providing him with daily hands-on experience with SCCM, Windows Server 2012 and Windows 8.

Read full bio
Back to top