mirror of
https://github.com/actions/runner-images.git
synced 2025-12-16 06:40:32 +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') {
|
if($env:AGENT_JOBSTATUS -eq 'Failed') {
|
||||||
try {
|
try {
|
||||||
|
if($Vm.PowerState -ne "PoweredOff") {
|
||||||
Stop-Vm -Vm $Vm -Confirm:$false -ErrorAction Stop
|
Stop-Vm -Vm $Vm -Confirm:$false -ErrorAction Stop
|
||||||
|
}
|
||||||
Set-Vm -Vm $Vm -Name "${VMName}_failed" -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]"
|
Write-Host "VM has been successfully powered off and renamed to [${VMName}_failed]"
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user