header image

WMI discovery

Posted by: | January 8, 2016 Comments Off on WMI discovery |

I’ve been working with System Center Configuration Manager this week. SCCM uses a lot of WMI. However, WMI discovery is still a bit of an art.

 

I needed to find the SMS_SCI_Component class.

 

If you know the namespace you can easily find the classes in that namespace but namespaces are hierarchical so you need to work down the tree.

The root namespace is at the top of the namespace tree so

C:\Scripts> Get-CimInstance -ClassName __NAMESPACE -Namespace root

Name
—-
subscription
DEFAULT
SCCMDP
CIMV2
msdtc
Cli
nap
MicrosoftIISv2
SECURITY
CCMVDI
NetworkModel
RSOP
SMS
ccm
StandardCimv2
WMI
AccessLogging
directory
Policy
InventoryLogging
Interop
Hardware
ServiceModel
Microsoft
aspnet

 

After a bit of digging I found I needed the sms namespace

PS C:\Scripts> Get-CimInstance -ClassName __NAMESPACE -Namespace ‘root\sms’

Name 
—-    
site_PS1

 

which leads to:

Get-CimInstance -ClassName SMS_SCI_Component -Namespace ‘root\sms\site_PS1’

 

What if you only know the class?

There’s a little trick using Get-WmiObject

Get-WmiObject -Namespace root -Recurse -List -Class SMS_SCI_Component

   NameSpace: ROOT\SMS\site_PS1

Name  
—-      
SMS_SCI_Component      

 

The trick is to start with the root namespace and use the –Recurse (search through all child namespaces) and –List (just give class details) parameters.  You’ll see a listing by namespace for each instance of the class discovered.

under: PowerShell and CIM, PowerShell and WMI

Comments are closed.

Categories