WMIC: Retrieving drive information

I had a need today to see what partitions were available on one of my servers. I generally try to use a command line whenever possible to solve problems like this.

So, I went down the rabbit hole of Google, and found some useful techniques.

Problem: Need to gather information about the physical and logical drives on a server.

Solution:  WMIC!

Most of the trick of WMIC is figuring out how to trim the abundant amounts of information to what is needed.

These examples will be run against a local computer. Another computer on the network may be accessed with the /node: and /user: options…

First off, let’s take a look at the types of information we can access about the physical drives.

wmic diskdrive list

Wow! That’s a lot of information! (Authoritative information about the diskdrive wmi class can be found at https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-diskdrive?redirectedfrom=MSDN)

Let’s simplify things down to the information that most people will be looking for

wmic diskdrive list brief

This yields information like this…

wmic diskdrive list brief
Caption DeviceID Model Partitions Size
Microsoft Virtual Disk \\.\PHYSICALDRIVE1 Microsoft Virtual Disk 1 8587192320
Micron 1100 SATA 512GB \\.\PHYSICALDRIVE0 Micron 1100 SATA 512GB 5 512105932800

Now, how about how the drives are logically used? (Yes, Microsoft has authoritative information at https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-logicaldisk)

Try this to get some information about the logical drives…

wmic logicaldisk get caption, description, providername, volumename, filesystem, size

Caption Description FileSystem ProviderName Size VolumeName
C: Local Fixed Disk NTFS 499099860992 OS
Q: Network Connection NTFS \\dc1\c$ 42580570112
X: Network Connection NTFS \\kfb\HomeFolders\home\stromd 1000202039296 Venus Drive

Caption is the assigned drive letter

Description tells whether it is local or network connected

FileSystem will normally be NTFS on a Windows system

ProviderName reflects the UNC to the drive

Size is the size of the logical drive

That is all that I needed to find today.

Posted in Learning, Technical.

Leave a Reply

Your email address will not be published. Required fields are marked *