mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
nitpick changes
This commit is contained in:
@@ -23,7 +23,7 @@ vCenter password (Example "12345678")
|
|||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$VMName,
|
[string]$vMName,
|
||||||
|
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
@@ -48,23 +48,23 @@ Import-Module $PSScriptRoot\helpers.psm1 -DisableNameChecking
|
|||||||
# Connection to a vCenter Server system
|
# Connection to a vCenter Server system
|
||||||
Connect-VCServer
|
Connect-VCServer
|
||||||
|
|
||||||
$Vm = Get-VM $VMName
|
$vm = Get-VM $vMName
|
||||||
|
|
||||||
if($env:AGENT_JOBSTATUS -eq 'Failed') {
|
if ($env:AGENT_JOBSTATUS -eq 'Failed') {
|
||||||
try {
|
try {
|
||||||
if($Vm.PowerState -ne "PoweredOff") {
|
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 {
|
||||||
Write-Host "##vso[task.LogIssue type=error;]Failed to power off and rename VM '$VMName'"
|
Write-Host "##vso[task.LogIssue type=error;]Failed to power off and rename VM '$vMName'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Move-VM -Vm $Vm -Datastore $TargetDataStore -ErrorAction Stop
|
Move-VM -Vm $vm -Datastore $TargetDataStore -ErrorAction Stop
|
||||||
Write-Host "VM has been moved successfully to target datastore '$TargetDataStore'"
|
Write-Host "VM has been moved successfully to target datastore '$TargetDataStore'"
|
||||||
} catch {
|
} 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