diff --git a/Update-VMGpuPartitionDriver.ps1 b/Update-VMGpuPartitionDriver.ps1 index 157b22b..58acb1a 100644 --- a/Update-VMGpuPartitionDriver.ps1 +++ b/Update-VMGpuPartitionDriver.ps1 @@ -36,7 +36,17 @@ While ($VM.State -ne "Off") { } "Mounting Drive..." -$DriveLetter = (Mount-VHD -Path $VHD.Path -PassThru | Get-Disk | Get-Partition | Get-Volume | Where-Object {$_.DriveLetter} | ForEach-Object DriveLetter) + $mnt = Mount-VHD -Path $VHD.Path -PassThru + Start-Sleep -Seconds 3 + $disk = $mnt | Get-Disk + if ($disk.IsOffline) { Set-Disk -Number $disk.Number -IsOffline $false } + $part = $disk | Get-Partition | Sort-Object Size -Descending | Select-Object -First 1 + if ($part.DriveLetter -notmatch '^[A-Z]$') { + $part | Add-PartitionAccessPath -AssignDriveLetter -ErrorAction SilentlyContinue | Out-Null + Start-Sleep -Seconds 3 + $part = $disk | Get-Partition | Sort-Object Size -Descending | Select-Object -First 1 + } + $DriveLetter = "$($part.DriveLetter):" "Copying GPU Files - this could take a while..." Add-VMGPUPartitionAdapterFiles -hostname $Hostname -DriveLetter $DriveLetter -GPUName $GPUName @@ -49,4 +59,4 @@ If ($state_was_running){ Start-VM $VMName } -"Done..." \ No newline at end of file +"Done..."