First you want to look at Win32_LogicalDiskToPartition
.
PS C:\> Get-WMIObject Win32_LogicalDiskToPartition | Select-Object Antecedent, Dependent | Write
Which gives on my system
Antecedent Dependent
---------- ---------
\\DESKTOP-JJASNFC\root\cimv2:Win32_DiskPartition.DeviceID="Disk #1, Partition #0" \\DESKTOP-JJASNFC\root\cimv2:Win32_LogicalDisk.DeviceID="C:"
\\DESKTOP-JJASNFC\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #1" \\DESKTOP-JJASNFC\root\cimv2:Win32_LogicalDisk.DeviceID="D:"
Query Win32_LogicalDisk
to get information about the drive letter.
Get-WMIObject Win32_LogicalDisk | Select DeviceID, Path | Write
yields for me
DeviceID Path
-------- ----
C: \\DESKTOP-JJASNFC\root\cimv2:Win32_LogicalDisk.DeviceID="C:"
D: \\DESKTOP-JJASNFC\root\cimv2:Win32_LogicalDisk.DeviceID="D:"
F: \\DESKTOP-JJASNFC\root\cimv2:Win32_LogicalDisk.DeviceID="F:"
Here the Path
property is connected to the Dependent
property we saw before.
In Win32_DiskPartition
we can find the device Id
Get-WMIObject Win32_DiskPartition | Select DiskIndex, MedPath | Write
Again, for me
DiskIndex Path
--------- ----
1 \\DESKTOP-JJASNFC\root\cimv2:Win32_DiskPartition.DeviceID="Disk #1, Partition #0"
0 \\DESKTOP-JJASNFC\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #0"
0 \\DESKTOP-JJASNFC\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #1"
Now, the most interesting part for you is when we query MSFT_Physicaldisk
.
Get-WmiObject MSFT_Physicaldisk -Namespace root\Microsoft\Windows\Storage | Select DeviceId, MediaType | Write
...
DeviceId MediaType
-------- ---------
1 4
0 4
Here, MediaType
is the key. A value of 4 means SSD, 3 means HDD. DeviceId
corresponds to the DiskIndex
.
So, if you join those 4 "tables" together you can achieve what you want. My Powershell-Fu is not good enough.
To recap: The joins are like
MSFT_Physicaldisk.MediaType, MSFT_Physicaldisk.DeviceID <-->
Win32_DiskPartition.DiskIndex, *Win32_DiskPartition.Path <-->
Win32_LogicalDiskToPartition.Dependent, Win32_LogicalDiskToPartition.Antecedent <-->
Win32_LogicalDisk.Path, Win32_LogicalDisk.DeviceID