1

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?

1 Answer 1

1

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.

Your Answer

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

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