From b6a0793d1e1c0b16fb3ad9238e75c084d473e099 Mon Sep 17 00:00:00 2001 From: A0 C8 Date: Wed, 11 May 2022 20:25:44 +0800 Subject: [PATCH] Fix disk path issue if attached disk more than one. --- Update-VMGpuPartitionDriver.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Update-VMGpuPartitionDriver.ps1 b/Update-VMGpuPartitionDriver.ps1 index 157b22b..11cdf2f 100644 --- a/Update-VMGpuPartitionDriver.ps1 +++ b/Update-VMGpuPartitionDriver.ps1 @@ -35,14 +35,19 @@ While ($VM.State -ne "Off") { "Waiting for VM to shutdown - make sure there are no unsaved documents..." } +if ($VHD -is [array]) { + $DiskPath = $VHD.Path[0] +} else { + $DiskPath = $VHD.Path +} "Mounting Drive..." -$DriveLetter = (Mount-VHD -Path $VHD.Path -PassThru | Get-Disk | Get-Partition | Get-Volume | Where-Object {$_.DriveLetter} | ForEach-Object DriveLetter) +$DriveLetter = (Mount-VHD -Path $DiskPath -PassThru | Get-Disk | Get-Partition | Get-Volume | Where-Object {$_.DriveLetter} | ForEach-Object DriveLetter) "Copying GPU Files - this could take a while..." Add-VMGPUPartitionAdapterFiles -hostname $Hostname -DriveLetter $DriveLetter -GPUName $GPUName "Dismounting Drive..." -Dismount-VHD -Path $VHD.Path +Dismount-VHD -Path $DiskPath If ($state_was_running){ "Previous State was running so starting VM..."