But if you happened to have any legacy, old, outdated servers lying around that you cannot upgraded just yet or maybe ever, WMI is maybe the only option you may have available to remotely manage servers from the command line.
And the WMIC is a command line interface to the WMI (Windows Management Instrumentation).
To get started, launch the command shell (CMD.EXE).
You can run WMIC utility interactively, from the WMIC prompt, 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:
From command prompt: WMIC CPU
You can run WMIC utility interactively, from the WMIC prompt, 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
From command prompt: WMIC CPU
OR
In interactive WMIC session: cpu
WMIC /NODE:<SERVERNAME> CPU
To run a WMI command on a remote computer
WMIC /NODE:<SERVERNAME> CPU
OR
In interactive session:
wmic os
wmic diskdrive get name, caption, mediatype, status, size, systemname, totalheads, totaltracks
wmic logicaldisk get caption, deviceid, drivetype, filesystem, status, volumename
wmic logicaldisk where deviceid="c:" get caption, deviceid, drivetype, filesystem, status, volumename
wmic service where name="mssqlserver" get name, caption, startmode, state, status
wmic pagefile
wmic pagefileset
wmic memcache
wmic memphysical
And finally, here are some links for additional information:
Using Windows Management Instrumentation Command-line:
To get information on the OS
wmic os
To display only SELECT fields from the output:
wmic diskdrive get name, caption, mediatype, status, size, systemname, totalheads, totaltracks
And here are some examples to get information on the logical disks:
wmic logicaldiskwmic 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, startmode, state, status
Wait a minute, what happened? I know I have SQL Server installed on this machine so what the hack?
The reason is simple, all my sql instances are named instances i.e. there is no default instance of SQL on this machine, which would have service name mssqlserver. So, I am going to modify my where condition like this to get all services with the "sql" anywhere in it's path name:
wmic service where "PathName like '%sql%'" get name, caption, startmode, state, status
That's better!
Here are few others that I have found useful at times.
wmic pagefile
wmic pagefileset
wmic memcache
wmic memphysical
And finally, here are some links for additional information:
Using Windows Management Instrumentation Command-line:
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc779482(v=ws.10)
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/bb742610(v=technet.10)
WMIC - Take Command-line Control over WMI:
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/bb742610(v=technet.10)
Windows PowerShell for WMI: