Blog Post

Easy to use WMI commands to query windows system

,

WMI has been around for a while and it has grown significantly over the years. With Microsoft's focus on powershell, WMI is maybe getting less visible in the public eyes.

This is not to say I am not a fan of powershell. But it can be bit daunting to get started with. So I wanted to share some WMI commands that I have found useful over the years as a SQL Server DBA.

To get started,  launch the command shell (CMD.EXE).

You can run wmic interactively or non-interactively. Once you get little comfortable with it, I think you would use the non interactive method more often.

But for learning purpose, lets start wmic in interactive mode by typing WMIC on the command prompt and hit enter. it should now display the WMIC command promot,  wmic:root\cli>

Here on I am just listing some informational commands that you can type in and view the results show up on your display:

Type /? and hit enter.  This would display all available WMIC commands reference.

To get information on the CPU on local computer

WMIC CPU

To run a WMI command on a remote computer

WMIC /NODE:<SERVERNAME> CPU

To get information on the OS

wmic os

To display only few fields from the output:

wmic diskdrive get name, caption, mediatype, status, size, systemname, totalheads, totaltracks

To get information on the logical disks

wmic logicaldisk
wmic logicaldisk get caption, deviceid, drivetype, filesystem, status, volumename
wmic logicaldisk where deviceid="c:" get caption, deviceid, drivetype, filesystem, status, volumename

Notice the use of where clause with one the output fields to filter the results.

Get information on a service:

wmic service where name="mssqlserver" get name, caption, servicetype, started, startmode, state, status

Here are few others that I have found useful at times.

wmic pagefile
wmic pagefileset
wmic memcache
wmic memphysical

And finally, WMI is much more powerful than what I have shared here!

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating