Skip to content

Instantly share code, notes, and snippets.

@pandiculator
Last active October 15, 2020 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandiculator/b3b780d8eef3170c5a55625f3e7ae6a9 to your computer and use it in GitHub Desktop.
Save pandiculator/b3b780d8eef3170c5a55625f3e7ae6a9 to your computer and use it in GitHub Desktop.
PowerShell.org Forum Response
$driveLetters = Get-Volume | Select -ExpandProperty driveLetter
foreach ($driveLetter in $driveLetters) {
Get-CimInstance CIM_LogicalDiskBasedOnPartition |
Where-Object {$_.Dependent -like "*DeviceID = `"$driveLetter`:`"*"} |
Select @{l='DriveLetter';e={$driveLetter}},@{l='Index';e={$_.Antecedent -match "Disk #[\d]+" |
ForEach-Object {$matches[0]}}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment