Describing the Location of a WMI Object

Conceptually similar to a Uniform Resource Locator (URL), a WMI object path is a string that uniquely identifies the namespace on a server, a class within a namespace, or instances of a class. An object path is hierarchical, and contains several elements that describe the location of the object in question. Like file paths, WMI object paths can be described in full or specified as a relative path.

The namespace of a WMI object is listed on the WMI reference page. For example, the location of most of the classes supported by the CIMWin32 WMI Providers are located in the \root\cimv2 namespace. The following PowerShell code describes a call to retrieve the Win32_ComputerSystem object on your local machine:

Get-WmiObject -Class Win32_ComputerSystem -Namespace "root\cimv2" -ComputerName "."

Alternately, a specific instance of Win32_LogicalDisk may have the following path from the SWbemObject.Path_ property.

\\Machine1\root\cimv2:Win32_LogicalDisk.DeviceID="C:"

The following example shows the relative path to this instance, as seen by displaying the Relpath property of the SWbemObjectPath object returned by the call to SWbemObject.Path_.

Win32_LogicalDisk.DeviceID="A:"

Note that DeviceID is the key property of the Win32_LogicalDisk class.

C++

The following table lists object path types and the associated methods that require object paths.

Object path type Method
Namespace
IWbemServices::OpenNamespace
Class
IWbemServices::ExecMethod
[IWbemServices::ExecMethodAsync](/windows/desktop/api/WbemCli/nf-wbemcli-iwbemservices-execmethodasync)
Class or Instance
IWbemServices::GetObject
[IWbemServices::GetObjectAsync](/windows/desktop/api/WbemCli/nf-wbemcli-iwbemservices-getobjectasync)
Instance
IWbemServices::DeleteInstance
[IWbemServices::DeleteInstanceAsync](/windows/desktop/api/WbemCli/nf-wbemcli-iwbemservices-deleteinstanceasync)

 

Script

Object paths can be constructed in several ways:

  • Retrieve the property of a method that returns an SWbemObjectPath object.
  • Retrieve the SWbemObject.Path_ property.
  • Create a string variable that contains the object path.

The following table lists the scripting objects that require object paths.

Scripting object Method
SWbemServices
AssociatorsOf
[AssociatorsOfAsync](swbemservices-associatorsofasync.md)
[Delete](swbemservices-delete.md)
[DeleteAsync](swbemservices-deleteasync.md)
[ExecMethod](swbemservices-execmethod.md)
[ExecMethodAsync](swbemservices-execmethodasync.md)
[Get](swbemservices-get.md)
[GetAsync](swbemservices-getasync.md)
[ReferencesTo](swbemservices-referencesto.md)
[ReferencesToAsync](swbemservices-referencestoasync.md)
SWbemObjectSet
Item