How to Get Rid of Orphaned Application Pools in SharePoint 2010
The other day I was working at a client’s site on their SharePoint Server 2010. I was creating and configuring service applications for their SharePoint environment when I ran into an interesting issue that I thought I will share with you.
At one point while I was creating a service, due to a typo the service wasn’t created but the application pool that I specified in the configuration got created. I know it was created because I could select it in the drop-down box in SharePoint when I tried to create the service application again. However, when I went to IIS 7 to delete the application pool it was not there. That was pretty confusing. At one point I deleted an existing service application and then recreated it. I experienced the exact same situation. The application pools were visible in SharePoint and not in IIS 7. I knew unless they are available in IIS 7 where you can manage them, they don’t really exist. I had to find a way to clean up the mess and get rid of the orphaned service application pools, especially because I wanted to use those names. After a little research I found the solution. Here’s how you can get rid of an orphaned application pool.
1. Start Windows PowerShell ISE located in Start, All Programs, Accessories, Windows PowerShell folder.. You can also use SharePoint 2010 Management Shell but I prefer to use Windows PowerShell ISE. You may have to install Windows PowerShell ISE if you haven’t already.
Best Practice: Use the Windows PowerShell ISE, which is 64-bit, instead of the 32-bit version called Windows PowerShell ISE (x86).
2. To view all the existing application pools type the following command and press enter.
Get-SPServiceApplicationPool | select Id, Name
You will notice that the left column lists the Ids and the right column lists the names. Here’s an example.
PS C:\Users\SP_Admin> Get-SPServiceApplicationPool | select Id, Name
4a3524ac-fb36-4b76-ab66-e8b4abca1cfc1 SeattlePro Search Service
cba42cbe-bb43-3524-8478-ae24826f904b SharePoint Web Services System
3. To delete the orphaned application pool type:
Remove-SPServiceApplicationPool -Identity “Name of Orphaned Application Pool”
What’s confusing here is that even though the command uses the switch called Identity, you don’t want to use the “Id”, you want to use the name of the application pool in the above command. For example, if the SeattlePro Search Service was the orphaned application pool that is available for you to use in SharePoint but you don’t see it in IIS 7, you will use the following command to delete it.
Remove-SPServiceApplicationPool -Identity “SeattlePro Search Service“
This should get rid of the orphaned application pool and you can recreate the pool by using the old name if you want.