Combine Get-disk and Get-volume information to get the disk number

Hello Experts,

I am trying to collect disk information from our Hyper-V cluster nodes. If I run Get-volume, I get all the information required except the Disk number. If I run Get-disk, it gives me the disk number but not the other important information like in Get-volume.

I’m having hard time combining these 2 together to get the disk number associated with Get-volume output.

Would appreciate any help in this matter.

Thank you in advance.

You could map it using the CIM class CIM_LogicalDiskBasedOnPartition

Hi,

Thank you for your response.

Unfortunately it only gives the information which has a drive letter. I want it against the CSVs in Hyper-V clusters. Get-volume gives me all I need but I would like to collect the disk number, which seems pretty difficult :frowning:

Thanks.

I just need to vote this issue up. I have the same issue tying up SAN Storage LUN’s with friendly names and DISK ID’s. the annoying thing is this is viewable at a glance in server manager, so why can’t it be done in powershell?!

The solution Matt offered works. If you need all the properties of Get-Volume, you can modify it. Here’s one way:

$vols = Get-Volume
$disks = Get-CimInstance cim_logicaldiskbasedonpartition

foreach ($vol in $vols)
{
    $vol | 
        Select-Object *,
                      @{n="Drive#"
                        e={$disks |
                            Where-Object {$_.Dependent.DeviceID -like ($Vol.DriveLetter + ":*")} |
                                Select-Object -ExpandProperty Antecedent |
                                    Select-Object -ExpandProperty DeviceID}}    
}