Discovering namespaces

Next point on the journey of discovery through CIM is finding the namespaces installed on a machine.  I showed how to do this using Get-WmiObject in PowerShell and WMI but this time round decided to come up to date and use Get-CimInstance

function get-cimnamespace {
param (
[string]$namespace = ‘root/cimv2’

Get-CimInstance -ClassName __NameSpace -Namespace $namespace |
select @{N=’Name’; E={“$($_.CimSystemProperties.NameSpace)/$($_.Name)”}}


This simply searches for instances of the __NameSpace class in a given starting name space. Default is root/cimv2.  By using select-object to create a calculated field I can append the name of the namespace to the current namespace to get the full path.

Next time I’ll show how to use recursion to dig through the namespaces we’re discovering to find any namespaces they contain.

This entry was posted in CIM, PowerShell and WMI, PowerShell V3, PowerShell v4. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s