From c552b1817c7fba1ff44a87818bad6c0a5411967c Mon Sep 17 00:00:00 2001 From: James Stringer <38541878+jamesstringerparsec@users.noreply.github.com> Date: Sun, 21 Nov 2021 05:40:09 -0800 Subject: [PATCH] Cleanup --- Update-VMGpuPartitionDriver.ps1 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Update-VMGpuPartitionDriver.ps1 b/Update-VMGpuPartitionDriver.ps1 index 9645833..5215258 100644 --- a/Update-VMGpuPartitionDriver.ps1 +++ b/Update-VMGpuPartitionDriver.ps1 @@ -68,34 +68,34 @@ foreach ($d in $drivers) { } $VM = Get-VM -VMName "GPUP" +$VHD = Get-VHD -VMId $VM.VMId If ($VM.state -eq "Running") { -[bool]$state_was_running = $true -} + [bool]$state_was_running = $true + } if ($VM.state -ne "Off"){ -"Attemping to shutdown VM..." -Stop-VM -Name $VMName -Force -} + "Attemping to shutdown VM..." + Stop-VM -Name $VMName -Force + } While ($VM.State -ne "Off") { -Start-Sleep -s 3 -"Waiting for VM to shutdown - make sure there are no unsaved documents..." -} - -$VHD = Get-VHD -VMId $VM.VMId + Start-Sleep -s 3 + "Waiting for VM to shutdown - make sure there are no unsaved documents..." + } "Mounting Drive..." $DriveLetter = (Mount-VHD -Path $VHD.Path -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 If ($state_was_running){ -"Previous State was running so starting VM..." -Start-VM $VMName -} \ No newline at end of file + "Previous State was running so starting VM..." + Start-VM $VMName + } + +"Done..." \ No newline at end of file