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

**URL:** <https://forums.powershell.org/t/combine-get-disk-and-get-volume-information-to-get-the-disk-number/15091>\
**Category:** PowerShell Help\
**Created:** [October 14, 2020, 10:42pm UTC](https://forums.powershell.org/t/combine-get-disk-and-get-volume-information-to-get-the-disk-number/15091 "2020-10-14T22:42:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxwelliwans](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@maxwelliwans](https://forums.powershell.org/u/maxwelliwans)\
**Post date:** [October 14, 2020, 10:42pm UTC](https://forums.powershell.org/t/combine-get-disk-and-get-volume-information-to-get-the-disk-number/15091/1 "2020-10-14T22:42:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [October 15, 2020, 2:26am UTC](https://forums.powershell.org/t/combine-get-disk-and-get-volume-information-to-get-the-disk-number/15091/2 "2020-10-15T02:26:50Z")

</div>

You could map it using the CIM class CIM\_LogicalDiskBasedOnPartition

> <https://gist.github.com/pandiculator/b3b780d8eef3170c5a55625f3e7ae6a9>

---

<div class="post-metadata">

**Author:** ![maxwelliwans](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@maxwelliwans](https://forums.powershell.org/u/maxwelliwans)\
**Post date:** [October 15, 2020, 3:02am UTC](https://forums.powershell.org/t/combine-get-disk-and-get-volume-information-to-get-the-disk-number/15091/3 "2020-10-15T03:02:58Z")

</div>

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 ☹

Thanks.

---

<div class="post-metadata">

**Author:** ![james-collins90](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@james-collins90](https://forums.powershell.org/u/james-collins90)\
**Post date:** [December 3, 2020, 7:03am UTC](https://forums.powershell.org/t/combine-get-disk-and-get-volume-information-to-get-the-disk-number/15091/4 "2020-12-03T07:03:21Z")

</div>

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?!

---

<div class="post-metadata">

**Author:** ![ralphmwr](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ralphmwr/32/1064_2.png) [@ralphmwr](https://forums.powershell.org/u/ralphmwr)\
**Post date:** [December 3, 2020, 8:07am UTC](https://forums.powershell.org/t/combine-get-disk-and-get-volume-information-to-get-the-disk-number/15091/5 "2020-12-03T08:07:04Z")

</div>

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}}    
}
```

&nbsp;

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/combine-get-disk-and-get-volume-information-to-get-the-disk-number/15091/6 "2024-05-16T20:28:13Z")

</div>

Closed on May 16, 2024, 8:28pm UTC


