WINDOWS TIP SHEET: All About Your Hard Drive

Look Mom, take 2: No-script hard drive info, this time using WMIC.

By Jeffery Hicks

Last time http://mcpmag.com/columns/article.aspx?editorialsid=1778 I showed you how to get WMI information about hard drive utilization without writing a single line of VBScript. If you don’t have PowerShell but are running XP or 2003 (no, I haven’t tried this yet on Vista to know what has changed), you can use WMI command line.

Open a command prompt and type WMIC. If you’ve never run the command before it will just take a moment for the utility to configure itself. When it is finished, you’ll be at a WMIC prompt. WMIC has an interactive mode like NSLOOKUP.

At the WMIC prompt, type:

Logicaldisk where (drivetype='3') get DeviceID,Size,Freespace

You should something similar to this:

DeviceID FreeSpace Size
C: 382550016 15726702592
E: 684658688 24280993792
S: 684658688 24280993792

If you want to connect to remote computer use this syntax:

/node:DC01 Logicaldisk where (drivetype='3') get DeviceID,Size,Freespace

If the computername has any non-alphanumeric characters, then enclose it in quotes. One advantage to using WMIC is that you can specify multiple computer names separated by commas:

/node:server1,server2

or a file list:

/node:@servers.txt

Type exit to return to the command prompt. Once WMIC is installed you can run the command directly without having to use WMIC interactively:

C:\>wmic logicaldisk where (drivetype='3') get deviceid,freespace,size >drivereport.txt

This makes it very easy to save results, write batch files or create a scheduled task.

Comment: http://mcpmag.com/columns/article.asp?EditorialsID=1789#post

Jeffery Hicks MCSE, MCSA, MCT is a senior network engineer with Visory Group. He's a contributing editor to ScriptingAnswers.com and the coauthor, with Don Jones, of "Advanced VBScript for Microsoft Windows Administrators" (Microsoft Press, http://tinyurl.com/g63nf ) and "PowerShell TFM" (SAPIEN Press, http://tinyurl.com/2v7dye ). Jeff is also the creator of several popular, script-related tools used for network and Exchange administration. He maintains a blog at http://jdhitsolutions.blogspot.com