Is there a way to retrieve a connection between a mountpoint (a volume which is mounted into the file system instead of mounted to a drive letter) and its belonging physical disk drive(s) with WMI?
For example I have got a volume mountpoint on a W2K8 server which is mounted to “C:\Data\” and the mountpoint is spreaded on the physical disk drives 2, 4, and 5 of the server (the Data Management of the Server Manager shows that) but I cannot find a way to get this to know by using WMI.
Volumes which have got a drive letter can be connected with the WMI-Classes Win32_DiskDrive --> Win32_DiskDriveToDiskPartition --> Win32_DiskPartition --> Win32_LogicalDiskToPartition --> Win32_LogicalDisk – but the problem is, that volume mountpoints aren’t listed in the class Win32_LogicalDisk, they are only listed in Win32_Volume. And I did not find a way to connect the class Win32_Volume with the class Win32_DiskDrive – there are missing some linking classes.
Does anyone know a solution?
The only way I know of is using the Win32 API to help.
You open a handle to the volume using Win32_Volume.DeviceID, modified slightly. You can open a handle to the volume using the format:
\\.\Volume{[GUID]}
You then need to issue IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS on the open handle to retrieve a VOLUME_DISK_EXTENTS structure. This structure will contain a list of physical disk ids for the volume.
Using these disk ids you can query WMI on Win32_DiskDrive.Index to get the matching disk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With