Thursday, January 27, 2005

How to Run a WMI Query from the Command Line

If you have some WMI Query you can use wbemtest *) to run it. But this is a little tedious as you first have to connect to the namespace etc.
An alternative is to do it from the command line using WMIC. Take this statement - it was part of an SMS error message I got:
SELECT __CLASS, __PATH, __RELPATH, Description, Manufacturer, Name, Status FROM Win32_NetworkClient
You can not use the statement directly, but it can easily be converted to WMIC style:
wmic path Win32_NetworkClient get __CLASS, __PATH, __RELPATH, Description, Manufacturer, Name, Status
Use the /Format switch to make the output more readable.

*) In case you do not know wbemtest, play around with it. Just search the Help and Support Center for wbemtest.

1 comment:

Alan Santos said...

Thank you very much! This is work great!

See you!