From 81ad74e82705913ddcdb590dd2832b7ee366fe8c Mon Sep 17 00:00:00 2001 From: "Andrey Mishechkin (GITHUB INC)" Date: Wed, 21 Oct 2020 21:06:52 +0400 Subject: [PATCH] if($Vm.PowerState -ne "PoweredOff") condition has been added --- images.CI/macos/move-vm.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/images.CI/macos/move-vm.ps1 b/images.CI/macos/move-vm.ps1 index 5b7140b1a..67efd933e 100644 --- a/images.CI/macos/move-vm.ps1 +++ b/images.CI/macos/move-vm.ps1 @@ -52,7 +52,9 @@ $Vm = Get-VM $VMName if($env:AGENT_JOBSTATUS -eq 'Failed') { try { - Stop-Vm -Vm $Vm -Confirm:$false -ErrorAction Stop + if($Vm.PowerState -ne "PoweredOff") { + Stop-Vm -Vm $Vm -Confirm:$false -ErrorAction Stop + } Set-Vm -Vm $Vm -Name "${VMName}_failed" -Confirm:$false -ErrorAction Stop Write-Host "VM has been successfully powered off and renamed to [${VMName}_failed]" } catch {