Search notes:
WMI Namespaces
WMI classes are hierarchically organized into
namespaces .
Some namespaces (such as
root\default,
root\cimv2,
root\subscription…) are created when the system
boots up .
The namespaces in a given namespace (for example root) can be shown like so:
PS C:\> get-cimInstance -namespace root -class __namespace | sort name
Name PSComputerName
---- --------------
CIMV2
Cli
DEFAULT
directory
Hardware
Interop
Microsoft
msdtc
PEH
RSOP
SECURITY
SecurityCenter
SecurityCenter2
ServiceModel
StandardCimv2
subscription
WMI
Similarly, the following command shows the namespaces under ROOT\CIMV2 (which happens to be he default namespace):
PS C:\> get-cimInstance -namespace root\cimv2 -class __namespace | sort name
The classes in given namespace can be showns like so:
PS C:\> get-cimClass -namespace root\cimv2
An instance of a particular class can then be obtained like so (note that -namespace root\cimv2 is not necessary here as it is the default namespace anyway):
PS C:\> get-cimInstance -namespace root\cimv2 -class win32_process
Recursively traversing namespaces
A
PowerShell script (that I found
here ) can be used to show the namespaces:
function get-wmiNamespace {
param($namespace='ROOT')
get-wmiObject -namespace $namespace -class __NAMESPACE | forEach-object { (
$ns='{0}\{1}' -f $_.__NAMESPACE, $_.name)
get-wminamespace -namespace $ns
}
}
# $wmiClasses=
get-wminamespace | forEach-object {
$namespace=$_
get-wmiObject -namespace $namespace -list | forEach-object {
$_.path.path
}
} | sort-object -unique