PowerShell for Windows Admins

May 26 2011   12:50PM GMT

root\wmi – speeding the testing



Posted by: Richard Siddaway
PowerShell v2, Windows 2008 R2, Windows 7, WMI

Testing the individual classes in root\wmi is a pain – so its time for some brute force.  I’ll select a group of classes and test the selection

gwmi -Namespace root\wmi -List system* | fw

 

I can then iterate through them calling get-wmiobject.

This is a command line activity so aliases are OK

gwmi -Namespace root\wmi -List system* | foreach {gwmi -Namespace root\wmi -Class $_.Name}

 

I could do this for all classes but it could become a bit difficult sorting out results if I get a lot of them.  We’ll see where this goes.

Comment on this Post

Leave a comment: