Created
July 18, 2022 12:22
-
-
Save codykonior/8ae29263afc3da69db9bdb84e3791993 to your computer and use it in GitHub Desktop.
How to follow from a drive letter to a physical disk in PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$drive = "C:" | |
Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object { $_.DeviceID -eq $drive } | |
$partition = Get-CimInstance Win32_LogicalDiskToPartition | Where-Object { $_.Dependent.DeviceID -eq $drive } | Select-Object -ExpandProperty Antecedent | Select-Object -ExpandProperty DeviceID | |
$diskDrive = Get-CimInstance -ClassName Win32_DiskDriveToDiskPartition | Where-Object { $_.Dependent.DeviceID -eq $partition } | Select-Object -ExpandProperty Antecedent | Select-Object -ExpandProperty DeviceID | |
Get-CimInstance -Class Win32_DiskDrive | Where-Object { $_.DeviceID -eq $diskDrive } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment