Mapping physical disks to logical drives
Posted by: Richard Siddaway
We have looked at physical disks and logical disks. We know there is a relationship between them.
disk drive – partition – logical disk
In WMI this maps to.
Win32_DiskDrive – Win32_DiskPartition – Win32_LogicalDisk.DeviceID
We have two classes that provide the links
Win32_DiskDriveToDiskPartition and Win32_LogicalDiskToPartition which we can use like this
Get-WmiObject -Class Win32_DiskDriveToDiskPartition | Select Antecedent, Dependent
Get-WmiObject -Class Win32_LogicalDiskToPartition | Format-List Antecedent, Dependent
but we then have to match the information ourselves. if we look at the information for the C: drive
Antecedent : \\RSLAPTOP01\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
Dependent : \\RSLAPTOP01\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #1"
Antecedent : \\RSLAPTOP01\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #1"
Dependent : \\RSLAPTOP01\root\cimv2:Win32_LogicalDisk.DeviceID="C:"
we can see that we get antecedent and dependent pairs – we can access these associations directly using a WQL query to find the ASSOCIATORS.
PS> Get-WmiObject -Query "ASSOCIATORS OF {Win32_DiskDrive.DeviceID=’\\.\PHYSICALDRIVE0′} " | Select __CLASS -Unique
__CLASS
——-
Win32_PnPEntity
Win32_ComputerSystem
Win32_DiskPartition
Win32_PhysicalMedia
Shows us that we have a direct association between the Win32_DiskDrive class and the Win32_DiskPartition class. Next we have to work out how to get this information for all drives and all partitions




