Celeb Glow
news | March 11, 2026

Given a virtual disk, get the pool it belongs to

I have this monstrosity:

Get-Volume | ForEach-Object { $VolObj = $_ $ParObj = Get-Partition | Where-Object { $_.AccessPaths -contains $VolObj.Path } $DiskObj = Get-Disk | Where-Object { $_.Number -eq $ParObj.DiskNumber } $PsDriveObj = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Name -contains $VolObj.DriveLetter } Get-StoragePool -IsPrimordial $false | ForEach-Object { $pool = $_ Get-PhysicalDisk -StoragePool $pool | ForEach-Object { $disk = $_ if ($disk.UniqueId -eq $volume_id) { $pool_id = $pool.UniqueId } } } ...
}

The problem with this piece of code is in the line if ($disk.uniqueid -eq $volume_id).

Instead of $volume_id I've tried .SerialNumber and UniqueId of the multiple objects (VolObj, ParObj, DiskObj and PsDriveObj) but these are either empty or return the wrong ID (the IDs of these objects are either vol*** since I run it on an EC2 instance or in the format of {...}), so the if is never true.

Is there a straightforward way of achieving this?

4

1 Answer

The following helped the poster with his problem:

Get-VirtualDisk -FriendlyName "VDisk01" | Get-StoragePool

References:

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy