mirror of
https://github.com/actions/runner-images.git
synced 2025-12-16 06:40:32 +00:00
Power off and renaming the failed VM has been addded to move-vm.ps1
This commit is contained in:
@@ -48,12 +48,21 @@ Import-Module $PSScriptRoot\helpers.psm1 -DisableNameChecking
|
|||||||
# Connection to a vCenter Server system
|
# Connection to a vCenter Server system
|
||||||
Connect-VCServer
|
Connect-VCServer
|
||||||
|
|
||||||
try
|
$Vm = Get-VM $VMName
|
||||||
{
|
|
||||||
Get-VM $VMName | Move-VM -Datastore $TargetDataStore -ErrorAction Stop
|
if($env:AGENT_JOBSTATUS -eq 'Failed') {
|
||||||
Write-Host "VM has been moved successfully to target datastore '$TargetDataStore'"
|
try {
|
||||||
|
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 {
|
||||||
|
Write-Host "##vso[task.LogIssue type=error;]Failed to power off and rename VM '$VMName'"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
{
|
try {
|
||||||
|
Move-VM -Vm $Vm -Datastore $TargetDataStore -ErrorAction Stop
|
||||||
|
Write-Host "VM has been moved successfully to target datastore '$TargetDataStore'"
|
||||||
|
} catch {
|
||||||
Write-Host "##vso[task.LogIssue type=error;]Failed to move VM '$VMName' to target datastore '$TargetDataStore'"
|
Write-Host "##vso[task.LogIssue type=error;]Failed to move VM '$VMName' to target datastore '$TargetDataStore'"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user