2
Answers

How to get all the Web sites and Web services deployed on IIS

Sreenath G

Sreenath G

13y
2k
1
 

Hi,

I am using the following logic to get the details..but I am not getting actual name of Site and Service. Any ideas on  what query should I use in place of IIsWebInfo to get all the details as required.

bool mFnGetIISWebInfo(string aStrServer)

        {

            try

            {

 

                string lStrRemotePath = "";

                string lStrOutPut = "";

 

                lStrRemotePath = @"\\" + aStrServer.Trim() + @"\root\MicrosoftIISv2";

 

                ManagementObjectSearcher lObjMSearcher = null;

 

                lObjMSearcher = new ManagementObjectSearcher(lStrRemotePath, "SELECT * FROM IIsWebInfo");

 

                foreach (ManagementObject lObject in lObjMSearcher.Get())

                {

                    PropertyDataCollection lObjProp = lObject.Properties;

 

                    foreach (PropertyData lObjPData in lObjProp)

                    {

                        lStrOutPut += lObjPData.Name + ": " + lObjPData.Value + "<br/>";

                    }

 

                    lStrOutPut += "<br/><br/>";

                   

 

                }

}

 

Please help out


Answers (2)