7

Unfortunately we had a situation where an IISRESET was performed by one user whilst another was creating a site collection - now the site collection can't be deleted.

When I go to central administration and try to select the site collection for deletion, it doesn't select at all. Additionally when I try to view the site collection it only shows the name - not the database or site collection administrator. The ULS logs don't show any errors either.

I tried to do a database repair with stsadm both with and without the deletecoppuption flag but that hasn't resolved the issue:

PS C:\Users\<redacted>> stsadm -url http://sharepoint/services -o databaserepair
-deletecorruption -databasename WSS_Content

<OrphanedObjects Count="0" />

I've also tried deleting the site using stsadm, but that doesn't work either.

PS C:\Users\<redacted>> stsadm -o deletesite -url http://sharepoint/services

<nativehr>0x80070003</nativehr><nativestack></nativestack>

Additionally when I try to enum sites to get the id of the collection so I can delete with the force flag, I get an error:

PS C:\Users\<redacted>> stsadm -o enumsites -url http://sharepoint/services
<Sites Count="3">   <Site Url="http://sharepoint" Id="0c18620b-11b4-4660-a65e-e75eb75a11c2" Owner="i:0#.w |<redacted>" SecondaryOwner="i:0#.w|<redacted>" ContentDatab ase="WSS_Content" StorageUsedMB="18.1" StorageWarningMB="0" StorageMaxMB="0"  />   <Site Url="http://sharepoint/projects" Id="1d517aa0-31bd-4a16-85b0-a32cb7d39aa7" Owne r="i:0#.w|<redacted>" SecondaryOwner="i:0#.w|<redacted>" ContentDatabase="WSS_Content" StorageUsedMB="1.9" StorageWarningMB="0" St orageMaxMB="0" />   **
<Site Error="&lt;nativehr&gt;0x80070003&lt;/nativehr&gt;&lt;nativestack&gt;&lt ;/nativestack&gt;" />**

Remove-spsite yields the following error:

PS C:\Users\<redacted>> remove-spsite http://sharepoint/services

Confirm
Are you sure you want to perform this action?
Performing operation "Remove-SPSite" on Target "http://sharepoint/services".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):y
remove-spsite : <nativehr>0x80070003</nativehr><nativestack></nativestack>
At line:1 char:1
+ remove-spsite http://sharepoint/services
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...mdletRemoveSite:
   SPCmdletRemoveSite) [Remove-SPSite], DirectoryNotFoundException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRemoveSi
   te

I've no idea how this can be resolved... Help!?

2
  • 2
    Have you tried Remove-SPSite -url "Your url"? I do not really understand why you are using stsadm in 2013, is there a particular reason? Oct 17, 2013 at 13:31
  • 2
    @RobertLindgren Tried that also, I've now included the results from that in an edit. This also shows an error.
    – Michael A
    Oct 17, 2013 at 14:04

4 Answers 4

20
SPContentDatabase.ForceDeleteSite 

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spcontentdatabase.forcedeletesite.aspx

use this method to force a delete:

SPWebApplication spWebApplication = SPWebApplication.Lookup(new Uri("http://mywebapplication")); // insert the webapplication

spWebApplication.ContentDatabases[0].ForceDeleteSite(new Guid("D0D529C1-DC06-4DB0-A8A3-81466E1E75DB"), true, false); // insert the ID from the errormessage

above is used for a console app

http://sharepointbox.blogspot.co.uk/2011_10_02_archive.html

and for a powershell script use:

$site = Get-SPSite http://siteurl

$siteId = $site.Id

$siteDatabase = $site.ContentDatabase 

$siteDatabase.ForceDeleteSite($siteId, $false, $false)

http://blog.claudiobrotto.com/2013/deleting-a-site-collection-that-cannot-be-deleted/

2
  • no probs happy to help!
    – Ali Jafer
    Oct 21, 2013 at 7:31
  • just solved my problem too! amazing powershell Mar 7, 2014 at 11:28
2

I had the same challenge and to resolve it this is what I did:

  1. I moved out other site collections from the content database containing the bad site collection using the command below

    Move-SPSite http://servername/sites/sitename -DestinationDatabase ContentDb2 iisreset

  2. I deleted the faulty content database using the command below:

    Remove-SPContentDatabase ContentDb1

  3. I recreated the content database and then moved the other site collections back into it using the command in (1):

    New-SPContentDatabase ContentDb1 -WebApplication http://servername -DatabaseServer enterprisedb Move-SPSite http://servername/sites/sitename -DestinationDatabase ContentDb2 iisreset

1

What about getting the SpSite first and then deleting it?

$s = Get-SPSite "http://sharepoint/services"
$s.Delete()

Or if you cant get the site using that method you could iterate through the site collections in the web application...

$spWebApp = Get-SPWebApplication "url here"   
foreach($site in $spWebApp.Sites)
{
    #Logic Here to get the specific site...
}
-1

Use powershell instead of stsadm to list all of your sites on the farm. In my experience some sites show up in Powershell and not in the user interface.

1
  • Please read the whole post; I've tried both
    – Michael A
    Oct 17, 2013 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.