WMI (Windows Management Instrumentation) – The Moniker

Introduction to WMI – The Moniker

It may surprise you that WMI Moniker is not something that I made up.  No, WMI moniker is an official Microsoft term to describe the path to an object that you wish to manipulate.  Always keep in mind that WMI starts by connecting to an object, for example Win32_Disk or Win32_Process.  Think of the moniker as the correct command to get a handle on the object that you wish to script.

Let us build up the moniker in three stages.  The moniker always begins with winmgmts, I think of winmgmts as a shell program.  To gain your own insight, run winmgmt from command line, note, here at the command line there is no ‘s’ in winmgmt.  However, when you are scripting you need the plural winmgmtS.  Don’t ask me why there is this inconsistency – ask Microsoft as it is their Moniker.

The path that you want is to the CIM database.  Another way of looking at our quest, is that the CIMv2 holds a library of objects and winmgmts is the librarian, who will service our request and find the reference to the object, for example, Win32_Process.

Stage 1 has three parts: winmgmts, CIM, and Win32_Process, let us join them with the correct syntax
winmgmts:root\Cimv2:Win32_Process

Stage 2,  so far so good, however we have omitted the tricky security section of the command.  While this security impersonate section is optional, many WMI scripts require authentication.

Mostly, I accept that you just need to add "{impersonationLevel=impersonate}!

The exclamation mark actually turns off the impersonation, or forces the script to use the default in the registry.

Stage 3 – CIMv2

  • Usually, I change the Namespace to root\cimv2 because I am mostly interested in Win32 objects like computers, disks, devices or event logs. (CIM means Common Information Model)
  • For Active Directory, I set the Namespace to root\directory\ldap
  • I leave the Namespace as root\default when I want the registry classes.

Guy Recommends SolarWinds’ Free Network MonitorSolarwinds Network Device Monitor

Thus utility makes it easy to check the health of a router or firewall.  Check the real-time performance, and availability statistics, for any device on your network.  Get started with an extensive collection of "out-of-the-box" monitors for popular network devices. Give Network Monitor a whirl – it’s free. Download your free Network Device Monitor

If you need more comprehensive network analysis software:
Download a free trial of NPM (Network Performance Monitor)

If you like this page then please share it with your friends

 


See more VBScript WMI examples:

WMI Tutorial   • WMI Who Logged On   • WMI WBEMTest   • Free WMI Monitor   • Free WMI Monitor

WMI Secrets   • VBScript Services   • WMI Techniques   • WMI Scriptomatic

WMI Home   • WMI Moniker   • Import CSVDE – Free Utility   • VBScript Echo   • WMI VBScript