SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have done an in-place upgrade of a SharePoint 2007 farm to SharePoint 2010. I am now trying to run:

stsadm -o enumallwebs

This command fails with the following error message after enumerating a couple of sites:

</Site>The site with the id 2371cdd6-5ec8-46cd-ab34-4a5be24d6a70 could not be found.

I have tried running:

stsadm -o databaserepair -url http://... -databasename ... -deletecorruption

but this command reports that there are 0 orphaned sites.

Is there another way to remove orphaned sites?

share|improve this question

Enumallwebs should list the sites that are orphaned too, so it is weird it fails!

Did you prepare for your upgrade properly by doing PreUpgradeCheck, and resolve all issues? Did you do enumallwebs on the site before upgrading? Orphans should be deleted before attempting an upgrade rather than after...

Make sure you read up on the new tools for preparing for upgrade before doing the actual upgrade. A good source is Joels article series here or my own upgrade white paper here that Joel also have included in his book on upgrade.

Normally you would get an output like this:

<Sites Count="2">
  <Site Id="e2a114b8-80c9-41f6-87bf-3feddf2ad9b6" OwnerLogin="Domain\username" InSiteMap="False"> 
    <Webs Count="1">
      <Web Id="064d8e7b-b349-4693-bd67-dcefed3bf466" Url="/sites/site_name" LanguageId="1033" TemplateName="STS#0" TemplateId="1" />
  <Site Id="f440114b8-79d9-32f6-87bf-4geddf2ad9b6" OwnerLogin="Domain\username" InSiteMap="True" HostHeader="">
    <Webs Count="1">
      <Web Id="12348e7b-c456-4693-bd67-efdegd3bf466" Url="/" LanguageId="1033" TemplateName="STS#0" TemplateId="1" />

Where the elements that has attribute InSiteMap="false" are the sites that are orphaned.

you could try (after doing backup etc) to delete the site using stsadm -o deletesite -siteid 2371cdd6-5ec8-46cd-ab34-4a5be24d6a70 -force

In general in-place upgrades are not reccomended due to the many ways it can go wrong. Read Joels article on the subject here.

share|improve this answer
Anders, Thanks for the answer. We detected the orphans before upgrading and tried to remove them then. This didn't work. Using the stsadm -o deletesite option actually created other problems. There are more than one site with the same Url (and how this happened is a completely different question!) so by using deletesite we delete all of them. We tested the in-place upgrade (even after reading Joel's article) and things worked fine. So we seem to be stuck with weird inconsistencies in the database. I'll backup the site collection which works and then delete the orphaned. I'll report back. – Björn Stenberg Aug 15 '10 at 12:01
When you use stsadm -o deletesite you must use the siteid parameter (as i specified) to specify a specific site, not several sites with same url. You get the site id from enumallwebs. – Anders Rask Aug 15 '10 at 18:52

Thanks to everyone of you. I just put it all together ...

#remove any sitecollection that is not found in the sitemap
$database = Get-SPContentDatabase -WebApplication "http://mywebapp"
#or just $database = @{name="MyContentDatabaseName"}
Foreach ($DBname in ${
    #"stsadm -o enumallwebs" gives back an XML which we can parse for the orphaned sites
    [xml]$allwebs = stsadm -o enumallwebs -databasename $DBname 
    #filter those that are missing in the sitemap and pass them back to stsadm to delete
    $OrphanedSites = $ | ?{$_.insitemap -match "false"}
    Foreach($site in $OrphanedSites){
        Stsadm -o deletesite -force -siteid  $site.Id -databasename $DBname -databaseserver $allwebs.Databases.Database.datasource
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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