0

I'm trying to enumerate and query a WMI WebAdministration class in remote machines. This is a code sample in C#, but same operation can be done from CIM Studio or WMI Tester tool

ManagementScope scope = new ManagementScope();
scope.Path = new ManagementPath(@"\\" + server + @"\root\WebAdministration");
ConnectionOptions options = new ConnectionOptions();
options.Impersonation = ImpersonationLevel.Impersonate;
options.EnablePrivileges = true;
options.Authentication = AuthenticationLevel.PacketPrivacy;
scope.Options = options;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT path FROM AuthenticationSection WHERE Path LIKE '%WebApp1%'");
searcher.Scope = scope;
foreach (ManagementObject os in searcher.Get()) //fails here
{
    Console.WriteLine("path - " + os["Path"].ToString());
}

This works when connecting pointing to one remote machine, but fails when pointing to another (with the error 0x80070032 "The request is not supported"). These 2 machines are seemingly identical. I might have missed something, but IIS config, security settings, installed roles, etc. look the same.

One important thing to state is that I'm able to successfully query WMI MicrosoftIISv2 classes in both machines. So this problem is unique to WebAdministration namespace

Searching around for this error, it seems to be thrown when the issue is "external" to WMI. Still banging my head to find out where it is coming from and why.

Appreciate any leads or ideas!

eranfu
  • 55
  • 1
  • 9
  • Try [`Rebuilding the WMI Repository`](http://blogs.technet.com/b/askperf/archive/2009/04/13/wmi-rebuilding-the-wmi-repository.aspx) – RRUZ Mar 12 '15 at 15:15
  • @RRUZ Thanks. Is there a point of rebuilding it if "winmgmt /verifyrepository" already returns 'consistent'? – eranfu Mar 12 '15 at 16:32
  • Based on my experience, some times is necessary rebuild even if the verification returns `consistent`. – RRUZ Mar 12 '15 at 16:36

0 Answers0