I have a site collection which is corrupted, it was not deleted correctly and now I cannot fully remove it.

It does not appear in the Central Admin, but it does with Powershell. Compatibility level appears empty. Somehow, the database where this site collection was, is also corrupted. It does not appear in the Central Admin, but it does via Powershell. I can't delete it either.

Querying $site.contentDatabase returns nothing, it looks like there is no connection between the site collection and the database.

I can't create the database again with the same name, or even delete the web application where this site collection was. Is there any way to force delete the site collection and the database?


there are couple of Methods to remove the orphan site.

Method 1 :

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

Method 2, try to use stsadm.

Try to use Old Fashioned Stsadm command.

stsadm -o deletesite -force -siteid e2a114b8-80c9-41f6-87bf-3feddf2ad9b6 -databaseserver DS1 -databasename DB1

Deleting the Orphan Sites in the Sharepoint

  • Thanks but site.contentDatabase returns nothing. There is no database assigned to the site collection. – garfield185 Jan 12 '16 at 15:23
  • check the blog their are 4 methods mentioned in it, try those – Waqas Sarwar MVP Jan 12 '16 at 16:21

did you try to play with : Get-SPDeletedSite and Remove-SPDeletedSite ?

  • Yes, no deleted site unfortunately – garfield185 Jan 6 '16 at 22:19
  • Ok so... I suppose that you see the site collection using Get-SPSite? What if you try to delete it using Remove-SPSite? Any Errors? Do you check for orphans items ? – Seb Jan 7 '16 at 12:21
  • I can't delete it either with Remove-SPSite. Remove-SPSite : Object reference not set to an instance of an object. Is it possible to check for orphan items somehow? – garfield185 Jan 7 '16 at 12:41
  • $CDBs = Get-SPContentDatabase ForEach ($CDB in $CDBs) { Write-Host "Detecting Orphans for " $CDB.Name $CDB.Repair($false) } sharepoint.stackexchange.com/questions/144701/… – Seb Jan 7 '16 at 12:47
  • Get-SPContentDatabase does not return this database. However Get-SPDatabase does. Using this code on the failing database generates an error: Exception calling "Repair" with "1" argument(s): "<nativehr>0x80004003</nativeh r><nativestack></nativestack>" At line:1 char:1 + $cdb.Repair($false) + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : NullReferenceException – garfield185 Jan 7 '16 at 14:34

If the database still showing in get-spdatabase then you have to delete the orphaned database first, see this post

$dbs = Get-SPDatabase 
$dbs | ?{$_.Exists -eq $false}  | %{Write-Host "DB"$_.Name"does not exist. Deleting and cleaning up references." -f red; $_.Delete();$_.Unprovision()}

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.