Windows Tip Sheet
All About Your Hard Drive
Look Mom, take 2: No-script hard drive info, this time using WMIC.
- By Jeffery Hicks
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:
or a file list:
Type exit to return to the command prompt. Once WMIC is installed you can run the command directly without having to use WMIC interactively:
Tech Help—Just An
Got a Windows, Exchange or virtualization question
or need troubleshooting help? Or maybe you want a better
explanation than provided in the manuals? Describe
your dilemma in an e-mail to the MCPmag.com editors
the best questions get answered in this column and garner
the questioner with a nifty Redmond T-shirt.
When you send your questions, please include your
full first and last name, location, certifications (if
any) with your message. (If you prefer to remain anonymous,
specify this in your message, but submit the requested
information for verification purposes.)
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.
Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.