Thursday, October 17, 2013

I can't delete a SharePoint web application! Now What?

I have recently ran into an issue where I go to delete a sharepoint web application and it fails with the error:  "Object not set to a reference of an object".  It turns out there are orphaned sites still associated to the web application in the farm configuration database.  Here is how you resolve this:

In SQL management studio:
select * from Objects (nolock) where Name like '%<name of the webapplication>%'
note the "Id" guid.
select * from SiteMap (nolock) where ApplicationId = '<Id guid from the above step>'
note the 'DatabaseId' guid.
Next step is to be done on a sharepoint server in the farm:
STSADM -O deleteconfigurationobject -id {DatabaseId guid from step above}
Repeat this for each row returned in the first step and then you will be able to successfully delete the web application from the farm.
Good luck and happy sharepoint'ing.