If you want to determine if an ApplicationPool exists in IIS7 you can use the following code:

        public bool Exists(string name)
        {
            bool result = false;

            using (ServerManager manager = new ServerManager())
            {
                result = manager.ApplicationPools.Any(t => t.Name == name);
            }

            return result;
        }

You can find the Microsoft.Web.Administration.dll in "%windir%\System32\inetsrv".

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.