SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a PowerShell script that creates a web application using New-SPWebApplication. It crashed for some reason a while back and now it keeps telling me the application pool exists. I've looked in IIS, in SharePoint Central Administration -> Web Applications and using PowerShell Get-SPServiceApplicationPool, but cannot find it anywhere. It seems that SharePoint has convinced itself the application pool is present, but I'm unable to remove it and start over.

Is there a way to persuade SharePoint that the application pool does not in fact exist so I can recreate the web application?

share|improve this question
up vote 1 down vote accepted

I've solved it. Needed to run the following code to unprovision the offending application pools:

var pool = Microsoft.SharePoint.Administration.SPWebService.ContentService.ApplicationPools["[Name of pool]"];

This removed the application pool from SharePoint allowing me to recreate the web application.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.