windowspowershellwmiwqlwsman

WSMAN and WMI System Properties


I'm trying to retrieve __PATH property in WQL query.

When I trying to enumerate it using WSMAN and WQL query, it returns only ProcessId .

Get-WSManInstance -Enumerate wmicimv2/* -filter "SELECT __PATH, ProcessId FROM Win32_Process"

But it is easy to make sure that __PATH is not null.

Get-WmiObject -Query "SELECT __PATH, ProcessId FROM Win32_Process"  -Namespace root/cimv2 

Why it is not possible to retrieve WMI System Properties (like __PATH) in enumeration request?


Solution

  • __PATH is WMI-specific metadata.

    A path (in WMI terminology) is a URL-like resource identifier that helps you locate a specific object.

    WSMan does not share that concept, but describes resources by referencing a ResourceURI (or class name, in your case wmicimv2/Win32_Process), and one or more key selectors to distinguish a unique instance. The "path", as such, are really contained in these two pieces of information:

    PS C:\> (Get-WSManInstance wmicimv2/Win32_Process -SelectorSet {Handle = 4}).Caption
    System