Sreenath G

Sreenath G

  • NA
  • 233
  • 310.6k

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

Jun 30 2011 1:29 AM
 

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)