iis management using wmi in c#

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

As I have looked all over, even MSDN, I cannot find much on iis management
using wmi in c#. Does anyone have sample code or any documentation. If so
please email to me (e-mail address removed)@4duffy.com
remove no.spam@ of course
 
WMI is wrapped by the System.Management namespace classes, so you you will
have to learn how to use these classes, but you'll also need to know how to
use the WMI classes and how they are mapped to the FCL classes.

IIS6 WMI provider classes are documented here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/iis/ref_mof_iiscomputer.asp

Following is a small example to get you started.

public class IISService {
static void Main() {
ConnectionOptions connection = new ConnectionOptions();
connection.Username = "admin"; // admin privileges needed to
connect to the WMI provider
connection.Password = "hispassword";
ManagementPath iisPath = new ManagementPath();
iisPath.Server = "iisServer"; //Server name of the server running
IIS6
iisPath.NamespacePath = @"root\MicrosoftIISv2"; // IIS6/W2K3 WMI
provider
iisPath.RelativePath = "IIsWebService.Name='W3SVC'";
ManagementScope scope = new ManagementScope(iisPath, connection);
using (ManagementObject nac = new ManagementObject(scope, iisPath,
null)) {
foreach(PropertyData pd in nac.Properties)
Console.WriteLine("Property = {0}\t\t Value = {1}",pd.Name,
pd.Value);
}
}
}
 
Back
Top