WMI / WMIC Scripting Guide

Wmic.exe
is native to Windows XP and 2003. The Windows Management Instrumentation Command-line (WMIC) utility provides a
command-line interface for Windows Management Instrumentation (WMI). WMIC is compatible with existing shells and
utility commands. Wmic is a great addition to the already powerful WMI subsystem. One of the benefit's that
immediatly jumps out is that you can send the output of wmic to a Comma Seperated Value (CSV) file, to XML,
and to HTML output, as well as the standard screen output.

One of the other powerful features is the "/Every" switch, that allows you to repeat the command at a
specified interval, in seconds. You can use the typical windows comman help shortcut "/?" after a command
to see what commands are available to you.

Try some of these examples on your computer. When wmic is run on your computer for the first time, it
can take a while to set itself up. After the first time it's run it will be much faster.

Scripting with WMIC.EXE

Something we should note also about WMIC, is that it automatically searches for every instance of an object, such as processors
Harddrives, NIC's etc... there is no need to do any looping, of multiple searches as WMIC will automatically probe for each instance.

Here is an example script that searches for the majority of information an IT administrator would probably
like to get a report on at least once a day. This script grabs, BIOS information, LogicalDisk(s) information, OS
version, Memory information, PlugNPlay errors, and other computer information. Somthing you may notice is that
LogicalDisk info will poll the mounted network drives as well as your CD-Rom, floppy etc... If you want strictly
physical drives, use the Win32_ class of "Win32_DiskDrive", and to just get the Mapped drive use
"Win32_MappedLogicalDisk" Everything is appended to a single file, and output is html.

WMI script examples

The following links provide useful scripts that we've written, we hope you will get plenty of valuable information from them

These scripts were mainly derived from the
Script-o-matic tool found on Microsoft's Site.

Inventory Script This script finds the following,
Dell Service Tag from bios, cpu, memory, hardrive, Service Pack and network setting information. It
will also report any hardware malfunctions that windows detects, basically when ever you'd see a yellow
exclaimation point in system summary. The Dell service tag isn't really just a Dell thing, other Bios
manufacturers use the "SerialNumber" field also. And on a similar note, if your looking for the dell
service tag and are running Linux, try using DMI-Decode
to obtain it. Output of the script