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 a Microsoft MVP in Windows PowerShell, Microsoft Certified Trainer and an IT veteran with over 20 years of experience, much of it spent as an IT consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He works today as an independent author, trainer and consultant. Jeff writes the popular Prof. PowerShell column for MPCMag.com and is a regular contributor to the Petri IT Knowledgebase and 4SysOps. If he isn't writing, then he's most likely recording training videos for companies like TrainSignal or hanging out in the forums at PowerShell.org.
Jeff's latest books are Learn PowerShell 3 in a Month of Lunches, Learn PowerShell Toolmaking in a Month of Lunches and PowerShell in Depth: An Administrators Guide.
You can keep up with Jeff at his blog http://jdhitsolutions.com/blog, on Twitter at twitter.com/jeffhicks and on Google Plus (http:/gplus.to/JeffHicks)