3

It is probably something easy that I am not seeing, but I created a web application through powershell using the new-spwebapplication command which created an app pool based on the name provided. But I screwed something else up later in the script and wanted to start over. I was able to delete the Web Application through Central Administration, but I cannot get rid of the App Pool that it was assigned to. There are no other Web Applications on the box except the central administration web site. And the managed account says that the Farm component using this account is Microsoft SharePoint Foundation Application Pool: SharePoint - MySites (This is a SharePoint Server Standard installation).

So my question is: How do I list the Application Pools? and How do I remove an Application Pool for a web site; not a service application?

6 Answers 6

-1

Have you tried deleting the AppPool using IIS manager? If you right click an AppPool and select View Applications you can see what web site the AppPool is attached to.

2
  • My only concern there was that SharePoint is the one that deployed this AppPool on all the servers in the farm so I did not want to go around it to remove it. Also I am not sure if deleting through IIS manager if it will let SharePoint know that the apppool is no longer there.
    – Anonymous
    Commented Jun 15, 2010 at 12:55
  • 3
    Do not delete SharePoint application pools directly from IIS
    – shufler
    Commented Feb 2, 2012 at 22:27
2

You can delete you content application pool if you have the guid for the app pool in concern.

To get the id:

$applicationPools = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools

Then remove the app pool using the id:

$applicationPools.Remove("b40a1044-a9dd-4042-9773-143eca0e8f70")
2

Actually the Gt-SPServiceApplicationPool only manages service app pools, not those used for content web applications

1

User2816's answer will indeed remove the SharePoint record of the application pool (thanks) but it does not remove the physical application pool from IIS.

The removal via IIS could be completed manually afterwards but I am not sure whether this is a complete removal from a SharePoint perspective and is an extra unnecessary step too.

One method that I tested (on SharePoint 2010 and 2013) was un-provisioning the application pool (see http://alstechtips.blogspot.com/2015/04/sharepoint-2013-how-to-add-and-remove.html) as follows....

$pool = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools | where {$_.Name -eq "<my app pool name>"}
$pool.UnprovisionGlobally()

Having checked both IIS and SharePoint records of the application pool afterwards, it appears to have been successfully deleted from both when using this method.

See https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.administration.spapplicationpool_members(v=office.14).aspx for the SPApplicationPool methods (including UnProvision)

1
  • Thanks Simao, great solution! My only suggestion is to use GUID instead of app pool name inside of 'where' condition
    – Egor
    Commented Sep 28, 2017 at 20:07
0

Get-SPServiceApplicationPool lists all of the SharePoint application pools.

To remove one, you would just type:

Get-SPServiceApplicationPool -Identity [name of app pool] | Remove-SPServiceApplicationPool

Run each time Get-SPServiceApplicationPool to verify if it has been deleted

1
  • Have you actually tried this? I think this only returns Service Application Pools, not Content Application Pools. Commented Jan 29, 2014 at 11:32
0

In case anyone wants to do it by using PowerShell, here is the correct way to delete a SharePoint Application Pool:

 Remove-SPServiceApplicationPool "Application pool name here"

If you have screwed up the above command might fail and you will need to first run the following commands and then remove the application pool:

Stop-Service -Name SPAdminV4
Start-SPAdminJob -Verbose
Start-Service -Name SPAdminV4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.