Thanks to blog.crowe.co.nz/archive/2006/06/01/644.aspx:
using System;
using System.DirectoryServices;
namespace IISSample
{
    static class Program
    {
        /// 
        /// The main entry point for the application.
        /// 
        [STAThread]
        static void Main()
        {
            const string WebServerSchema = "IIsWebServer"; // Case Sensitive
            string ServerName = "LocalHost";
            DirectoryEntry W3SVC = new DirectoryEntry("IIS://" + ServerName + "/w3svc");
            foreach (DirectoryEntry Site in W3SVC.Children)
            {
                if (Site.SchemaClassName == WebServerSchema)
                {
                    Console.WriteLine("WebSite Instance ID : " +Site.Name);
                    foreach (string PropertyName in Site.Properties.PropertyNames)
                    {
                        Console.WriteLine(PropertyName);
                        PropertyValueCollection pvc = Site.Properties[PropertyName];
                        foreach(object Value in pvc)
                            Console.WriteLine("  " + Value.ToString());
                    }
                }
                Console.WriteLine("".PadRight(80, '-'));
            }
        }
    }
}
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment