PowerShell 5 on Windows Server 2022
I would like to mount a VHDX and continue with an updated Partition
object, but the one returned by Add-PartitionAccessPath -PassThru
isn't up-to-date as it doesn't contain the new mount-point:
$ImagePath = 'C:\file.vhdx'
$AccessPath = 'C:\dir\'
Mount-DiskImage -ImagePath $ImagePath -NoDriveLetter -Access ReadOnly -PassThru |
Get-Disk | Get-Partition | ? Type -Eq Basic |
Add-PartitionAccessPath -AccessPath $AccessPath -PassThru |
Format-List
output:
UniqueId : {00000000-0000-0000-0000-000100000000}60022480208BAE8FEC721CF4EDB71157
AccessPaths : {\\?\Volume{ff5a0fa9-eb5b-4d8d-9c22-0f0faecb321b}\}
DiskNumber : 22
DiskPath : \\?\scsi#disk&ven_msft&prod_virtual_disk#2&1f4adffe&0&000008#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
DriveLetter :
Guid : {ff5a0fa9-eb5b-4d8d-9c22-0f0faecb321b}
IsActive : False
IsBoot : False
IsHidden : False
IsOffline : False
IsReadOnly : False
IsShadowCopy : False
IsDAX : False
IsSystem : False
NoDefaultDriveLetter : False
Offset : 16777216
OperationalStatus : Online
PartitionNumber : 2
Size : 2 TB
Type : Basic
As you can see, the AccessPaths
property of the Partition object doesn't contain $AccessPath
.
Is it an expect behaviour? What should I do to continue the pipeline with an "up-to-date" Partition Object?