Separate VM resizing and moving into two different scripts (#7584)

This commit is contained in:
Vasilii Polikarpov
2023-05-17 16:42:02 +02:00
committed by GitHub
parent eb53372646
commit 4ca86478ee
3 changed files with 88 additions and 15 deletions

View File

@@ -66,7 +66,7 @@ try {
$vm = Get-VM $VMName
if (($env:AGENT_JOBSTATUS -and $env:AGENT_JOBSTATUS -eq 'Failed') -or ($JobStatus -and $JobStatus -eq 'failure')) {
try {
if($vm.PowerState -ne "PoweredOff") {
if ($vm.PowerState -ne "PoweredOff") {
Stop-VM -VM $vm -Confirm:$false -ErrorAction Stop | Out-Null
}
Set-VM -VM $vm -Name "${VMName}_failed" -Confirm:$false -ErrorAction Stop | Out-Null
@@ -84,11 +84,3 @@ try {
Write-Host "##vso[task.LogIssue type=error;]Failed to move VM '$VMName' to target datastore '$TargetDataStore'"
exit 1
}
try {
Write-Host "Change CPU count to $CpuCount, cores count to $CoresPerSocketCount, amount of RAM to $Memory"
$vm | Set-VM -NumCPU $CpuCount -CoresPerSocket $CoresPerSocketCount -MemoryMB $Memory -Confirm:$false -ErrorAction Stop | Out-Null
} catch {
Write-Host "##vso[task.LogIssue type=error;]Failed to change specs for VM '$VMName'"
exit 1
}