Cleaning up an Orphaned Site Collection

An orphaned site collection is a site collection that exists in the database but not in the site map. So there is no way of navigating to it from the web browser. Usually it is the remnant of a site that was deleted or moved. You will want to make sure you have a backup of the database prior to starting this procedure; you may also take a moment to check and see if a duplicate site exists at the same url.

Run;
Stsadm –o preupgradecheck
To see if you have any orphaned site collections note the content database name that contains the orphaned site collection.

Example of orphaned site collection from preupgrade check –
– /siteurl (Data Source=<sqlServerName;Initial Catalog=<ContentDatabaseName>;Integrated Security=True;Enlist=False;Connect Timeout=15)

Now run;
Stsadm –o enumallwebs–databasename <ContentDatabaseName> –databaseserver <DatabaseServer> >c:\<ContentDatabaseNameOrphans>.txt

This will generate a list of sites and webs and their respective GUIDs.
Example;
Orphaned
– Site Id=”cbca9688-9105-46ad-ab0b-0042a652b6eb” OwnerLogin=”Domain\user” InSiteMap=”False”
Webs Count=”1″
Web Id=”f368a039-a4ee-4d49-93db-91b239f03435″ Url=”/siteurl”
Not –Orphaned
– Site Id=”a46cb97e-29a9-4dfc-a2e4-00c2be049756″ OwnerLogin=”Domain\user” InSiteMap=”True”
Webs Count=”1″>
Web Id=”344f9c51-f00d-499b-a5f0-d5eaa4dfab6a” Url=”/siteurl_1″

You are looking for a web url that matches /siteurl from the preupgradecheck report. Check the line above for the site GUID (Site Id) and confirm that “InSiteMap=”False”. This is your orphaned site collection. Note the Site GUID as you will need it to continue. (Not the web GUID!) Also be sure you are confirming that “InSiteMap=”False””. It is possible that a site with the same URL might exist in the database but be correctly registering to the site map.

To remove the orphan – Since the site is not accessible from the web application it is unlikely that the content is needed. However I still strongly suggest that a current backup of this database exist before purging the site collection from the database.

To delete run;
Stsadm –o deletesite –force –siteid <SiteID/Guide noted from above> –databasename <ContentDatabaseName> –databaseserver <DatabaseServer>

It should reply “Operation completed successfully”.

You can now re-run preupgradecheck or enumallwebs to confirm that the site no longer exists.

Clean up an environment before upgrade (SharePoint Server 2010)

Advertisements

About Mr_SHeister

Geek, Dad, SharePoint Administrator
This entry was posted in SharePoint and tagged , , , . Bookmark the permalink.

3 Responses to Cleaning up an Orphaned Site Collection

  1. tradmanwp says:

    I put this together, just in case someone needs a quick fix …

    #remove any sitecollection that is not found in the sitemap
    $database = Get-SPContentDatabase -WebApplication “http://mywebapp”
    #or just $database = @{name=”MyContentDatabaseName”}
    Foreach ($DBname in $database.name){
    #”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 = $allwebs.Databases.Database.site | ?{$_.insitemap -match “false”}
    Foreach($site in $OrphanedSites){
    Stsadm -o deletesite -force -siteid $site.Id -databasename $DBname -databaseserver $allwebs.Databases.Database.datasource
    }
    }

  2. Atiq says:

    HI Please suggest. I have following orphaned site id:

    And the web application on which this orphaned site exists is “SharePoint Central Administration v4” meaning main central admin site. I am bit confuse in deleting this orphaned site because InSitemap is true and this may cause my central admin site to crash so please suggest

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s