Last active
October 15, 2020 12:03
-
-
Save pandiculator/b3b780d8eef3170c5a55625f3e7ae6a9 to your computer and use it in GitHub Desktop.
PowerShell.org Forum Response
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
$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