You can use
wmic to do this. You may wish to export it to a text file (
>output.txt) and view without word wrapping since the tabular output can get very wide.
To list all partitions (look at the
BootPartition member to check if it's marked as
To list just active partitions, filter with
wmic partition where BootPartition=true
To filter which columns are displayed, use
wmic partition where BootPartition=true get DeviceID,Size
wmic partition get DeviceID,Size,BootPartition
For more information on
partition members, see the Win32_DiskPartition documentation.
Data type: boolean
Access type: Read-only
Partition is the active partition. The operating system uses the active partition when booting from a hard disk.
Take a look at the WQL syntax for more information on the usage of
where. Take a look at
wmic partition get /? for more information on
wmic you have added advantages with remote management using the
/node:<servername or ip> switch (see
wmic /node /? for more information. As per Microsoft:
WMIC can be used from any computer with WMIC enabled to remotely manage any computer with WMI. WMIC does not have to be available on the remotely managed computer in order for WMIC to manage it.
If you can figure out some way of programmatically (e.g. batch script) getting the drive letter from the disk and partition index, you may wish to use a
for loop with the members
Index (disk and partition indexes, respectively).