Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

1 Answer

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]"];
pool.UnprovisionGlobally();

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

share|improve this answer
add comment

Your Answer

 
discard

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.