SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

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


To run a WMI command on a remote computer


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!

Mission: SQL Homeostasis

Drupal is a Senior SQL Server consultant with over 20 years of experience in engineering innovative SQL Server solutions for high growth organizations. A truly SQL Server specialist and IT generalist, Drupal is a certified MCDBA, Oracle OCP-DBA and IBM WebSphere Administrator. He is also ITIL V3 certified at the Foundation and Intermediate levels as well as PMP.


Leave a comment on the original post [sqlpal.blogspot.com, opens in a new window]

Loading comments...