WMI Namespace and __Genus property confusion

My question is less to do with scripting as a whole, and more to do with WMI in a general sense. I've been writing a program in C# to scavenge information out of WMI as a project (I know many great tools out there exist already, but this is both for learning and custom tailored to an environment I manage), and I've come across a few oddities. Currently tripping me up is the following snippet below:

using System.Management;

ManagementClass managementClass = new ManagementClass(new ManagementPath(@"\\" + pHostName + @"\root\" + pNameSpace));

EnumerationOptions enumOptions = new EnumerationOptions();
enumOptions.EnumerateDeep = false;

foreach(ManagementObject wmiClass in managementClass.GetSubclasses())
{
    Console.WriteLine(wmiClass["__Class"].ToString());
}

Given the definition of System.Management.ManagementClass under both the MSDN documentation and the VS Documentation, which I'll paraphrase pretty heavily to say it represents a CIM class, and the definition for the GetSubclasses() method which returns a collection of all subclasses under a class (under a class being the key phrase there), the only logical conclusion I can make as to why this works is that a Namespace in WMI is actually an instance of a class, which sounds incredibly wrong.

Are Namespaces actually instances of classes in WMI? On another note, what's the deal with the __genus property of classes? Why is the following a perfectly acceptable WQL:

select * from meta_class where __class like "%win32%" and __superclass like "%process%"

but this is not:

select * from meta_class where __class like "%win32%" and __genus is 2
select * from meta_class where __genus = 1

Neither of the above work, but are both valid and populated properties of classes when a query like the first is performed.

TL;DR; (but I hope you do Read) Are WMI Namespaces actually instances of a higher class? Additionally, why can I query something like __superclass, but not __genus?

Sincerely,

Really confused

  • Edited by Inkrement Wednesday, September 02, 2015 4:57 PM tl;dr
September 2nd, 2015 4:37pm

I'm a little confused by this answer. Are __class and __superclass  not defined as filters as well? Because querying based on that works fine, only __genus seems to have issues.

  • Edited by Inkrement Wednesday, September 02, 2015 5:07 PM
Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2015 4:58pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics