How to delete orphan configuration objects from SharePoint farm

The information in this blog is intended for orphan configuration objects and NOT orphan SharePoint Sites in the Content / Configuration Database. If you are looking for clearing the Orphan SharePoint Sites, check https://blogs.technet.com/b/corybu/archive/2007/05/31/sharepoint-orphans-explained.aspx

Note: Please be VERY careful when executing the deleteconfigurationobject command, if this command is not used in the correct way (if you end up deleting the wrong object) there is NO way to revert back the changes and it has the potential to render your Configuration Database useless, hence you may require to restore / rebuild your SharePoint farm !!!

Update: Running this command without explicit approval from SharePoint Product Group is not supported, use the information available in this blog ONLY IN TEST ENVIRONMENT to ensure your SharePoint environment has the issue described here, once confirmed open a support case with Microsoft and let them get approval from SharePoint Product Group.

Disclaimer: This posting is provided "AS-IS" with no warranties, and confers no rights. Use this information at your own risk, I or Microsoft are not responsible for any damage which may occur due to wrong usage of this command.

Lets consider a scenario of a site called SharePoint – 80 which was deleted sometime back but when you go to Central Administration > Operations > Timer Job Definitions you see an Immediate Alerts job still exists as below.

clip_image002[4]

The above timer job should have got deleted when the SharePoint – 80 site was deleted however somehow its left out and may interfere with other alert timer jobs.

To get rid of this timer job we will need the Configuration ID of the timer job which can be found by looking at Internet Explorer status bar while pointing your mouse cursor on the orphan timer job. Note down the GUID after JobId=

clip_image002[6]

Run the following command and replace objectId with above GUID number.

stsadm.exe -o deleteconfigurationobject -id <objectId>

You just got rid of your Orphan Immediate Alerts timer job!

Now lets take a scenario of an orphan application pool. ‘Orphan application pool’ is an object which is visible when you browse to Central Administration > Operations > Service Accounts > Choose Web application pool > Choose Windows SharePoint Services Web Application. Here in the drop down you see an orphan app pool which actually doesn’t exist on any of the web front ends (and also this app pool isn’t utilized for any web applications). Orphan app pool wouldn’t be listed in timer job definitions so that makes our job little difficult.

(Note: We are just going to read data from SQL Server and not perform any write operation as direct database modification is not supported for SharePoint databases – https://support.microsoft.com/kb/841057)

(Also ensure you have a good backup of your SharePoint Farm just in case if you accidently end up changing anything in database directly)

Open SQL Server Management Studio for SQL Server which hosts SharePoint databases > New Query

SELECT Id, Name, Status, Properties

FROM Objects

WHERE (Name LIKE 'SharePoint - 80')

 

(Here SharePoint – 80 is our orphan app pool name)

Now; it would give you a few entries; look in properties and note down the ID of the one which shows <object type="Microsoft.SharePoint.Administration.SPApplicationPool, …. >

clip_image002[8]

Again, run the following command and replace objectId with above GUID number to get rid of the orphan application pool.

stsadm.exe -o deleteconfigurationobject -id <objectId>