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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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: