Thursday, May 28, 2009

Testing WMI from the command line

wmic is a command line utility that can be used to test WMI queries. Unfortunately it uses a syntax that's slightly different from WQL.

So instead of

select * from win32_share

to get a list of shares, in wmic this would be:




for a more concise listing. SHARE is an alias for win32_share.

To see a list of all available alias, run wmic /?

To get a list of shares available on a remote computer (e.g., remotecomputer1):

wmic /node:remotecomputer1 SHARE LIST BRIEF

The /node switch specifies the computer against which the query will be run. There's a /user switch and a /password switch in case the user needs to logon.

No comments :

Post a Comment