PowerShell for Windows Admins

Mar 28 2014   2:35PM GMT

Discovering namespaces

Richard Siddaway Richard Siddaway Profile: Richard Siddaway


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.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: