Using PowerShell to Create a SharePoint Service Application Pool
There are situations where creating a service application pool in SharePoint Server 2013 using PowerShell comes handy. Well, you can also use the same command for SharePoint Server 2010. Here’s the command.
New-SPServiceApplicationPool -Name “SITPUG Search Service Application Pool” -Account SITPUG\SP_Search
Where “SITPUG Search Service Application Pool” is the name of the application pool that you want to create. I used quotes because there are spaces in the name. SITPUG is the name of the domain and SITPUG\SP_Search is the service account in the SITPUG domain that will be used by the application pool. The result will be something similar to this:
SITPUG Search Service Application… SITPUG\SP_Search
To view all the existing application pools you can use the following command.
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-fc36-4b76-ab66-e8b4abca1cfc1 SITPUG Search Service Application Pool
cba42cbe-bb43-3525-8457-ae24846b90c4 SharePoint Web Services System
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.