Get disk and partition numbers for drive letter via WMI

C

Computer Guru

If I query WMI for mounted drives of type 3 (physical hard drives)
and
end up with a letter (like D:), how can I use WMI to get the correct
corresponding partition and drive values for drive D:\ ?

Is it possible to even get the entire ARC path from there?
AS in, multi(w)disk(x)rdisk(y)partition(z)


That would be nice, but I'm willing to settle for just rdisk() and
partition() (basically the drive number and the partition number)


Thanks!
 
J

Jonathan Liu [MSFT]

Once you get you physical drive you get it's associating partitions, which
will look like something like this if you have 2 partitions:

WQL Query: associators of {Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"}

Win32_DiskPartition.DeviceID="Disk #0, Partition #0"
Win32_DiskPartition.DeviceID="Disk #0, Partition #1"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top