Wednesday, March 19, 2014

Deleting orphaned sites in SharePoint

If you have SharePoint 2007 database attached to SharePoint 2010 Server and you want to to delete some sites from the SharePoint 2007 instance. But when you try to go to "Site Actions > Site Settings" you face "Error , File Not Found"!!
and when you try the PowerShell normal commands, like stsadm -o -deletesite -url <url>  and delete-spsite -url <url> -identity <id> , it says  "Cannot find an SPSite object with Id or Url: xxxx "

You have to follow the right way to delete this sites:

1- Get the database name of the SharePoint 2007 instance: 
Go to the SharePoint 2010 Central Administration>Backup and Restore>Perform a Back Up , and get the database name under SharePoint 2007 web application

2- Get the WebID of the sites: 
In PowerShell use this command; stsadm -o enumallwebs -databasename <SP2007Database> > C:\Allwebs\Allwebs.xml , open the AllWebs.xml and find the url of the site you want to delete and get its ID from the same line.

3-Delete the site:
Use this command; stsadm -o deleteweb -force -webid <SiteID>  -databaseserver <DSName> -databasename <DBName>

Cheers,

No comments:

Post a Comment