mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
if($Vm.PowerState -ne "PoweredOff") condition has been added
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user