To call the function use:  this.DumpIISInfo(new DirectoryEntry("IIS://localhost/w3svc"));
/// <summary>
        /// Dump iis info
        /// </summary>
        /// <returns>
        /// 0 = All IIS information is written to the console
        /// 1 = Parameter entry was null
        /// </returns>
        public int DumpIISInfo(DirectoryEntry entry)
        {
            if (entry == null) { return 1; }

            foreach (DirectoryEntry childEntry in entry.Children)
            {
                using (childEntry)
                {
                    Console.WriteLine(string.Format("Child name [{0}]", childEntry.Name));
                    foreach (PropertyValueCollection property in childEntry.Properties)
                    {
                        Console.WriteLine(string.Format("[{0}] [{1}] [{2}]", childEntry.Name, property.PropertyName, property.Value));
                    }
                    if (childEntry.Children != null)
                    {
                        this.DumpIISInfo(childEntry);
                    }
                }
            }

            return 0;
        }

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.