Force Delete Corrupted Site Collections in SharePoint using PowerShell

There is a strange issue in SharePoint 2013 environment today! One of the site collection provisioned via custom code is unreachable with a “404 page not found” error. However, the particular site is listed under central administration >> View all site collections! But no further details such as the content database, etc., are available for the site collection in Central Administration.

We concluded that the site collection is “Corrupted!”. There are many scenarios where a site may go corrupted, such as: Storage media failure, network connectivity issues, incorrect usage of PowerShell cmdlets (E.g., If you use Copy-SPSite without the “DestinationDatabase” parameter, You’ll end up in a corrupted site!), etc.

So, We tried deleting the site collection from SharePoint central admin, but SharePoint central administration didn’t let me select and delete the site. I tried STSADM -o DeleteSite and Remove-SPSite PowerShell cmdlet with no luck!

Stsadm and PowerShell ways resulted with an Error:  <nativehr>0x80070003</nativehr><nativestack></nativestack>

sharepoint delete corrupt site collection
sharepoint cannot delete site collection

Solution: How to Delete Corrupted Site Collections in SharePoint?

We can delete corrupt site collections with either STSADM or PowerShell in the below methods.

STSADM to delete corrupt site collection:
Step 1: We need the site ID, Database Server, Database name parameters of the site we need to delete. Run:  

 stsadm -o EnumAllWebs > SitesList.xml

This produces an XML file with details such as site collection IDs, content database, database server, etc., as below.

How to force delete a Site Collections using PowerShell

Step 2: Extract required parameter values and supply it to STSADM -o DeleteSite as:

stsadm -o deletesite -force -siteid “1252fd8f-a0ea-4ef9-9b66-4715f8e44b37” -databaseserver SP13-Ent-SQL01 -databasename SP13_Intranet_Content

How to delete a Site Collections using stsadm

The Same method applies to corrupted site (web) as well. E.g.:
stsadm -o deleteweb -force -webid <Web ID> -databasename <database name> -databaseserver <database server name>

Delete corrupt site collection with PowerShell:

Use this PowerShell script to delete a corrupted site collection in SharePoint.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$CorruptedSiteURL ="https://intranet.crescent.com/sites/sales"

#Get the site collection
$site = Get-SPSite $CorruptedSiteURL

#Get the GUID of the site collection
$siteGUID = $site.Id
Write-host "Site collection GUID:"$siteGUID

#Get the content Database of the Site collection
$siteDatabase = $site.ContentDatabase 

#Force delete the site collection
$siteDatabase.ForceDeleteSite($siteGUID, $false, $false)

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

2 thoughts on “Force Delete Corrupted Site Collections in SharePoint using PowerShell

  • Hi Salauddeen,

    Wonderful article!
    I have one clarification, how we can delete the orphaned personal sites from SharePoint on-premise using Rest API?

    Reply
  • Really Very Helpful. Thank you Salaudeen 🙂

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *