lElOUCHE_79
Enthusiast
Enthusiast

Update multiple VCSA with PowerCLI

Hello

I have the below script to update VCSA, I'm looking for assistance in order to be able to update multiple VCSA in parallel.

Write-Host "vCenter authentication information" -BackgroundColor Yellow
$vCenter = 'local.local-lab.com'  
$username = 'administrator@vsphere.local'  
$password = 'XXXXXX'  

Write-Host "Login to $vCenter" -BackgroundColor Yellow
Connect-CisServer -Server $vCenter -User $username -Password $password

Write-Host "Get CIS Service for pending updates" -BackgroundColor Yellow
$updateService = Get-CisService -Name "com.vmware.appliance.update.pending"
$availableVersions = $updateService.list("LOCAL_AND_ONLINE")

Write-Host "Get available latest version" -BackgroundColor Yellow
$latestVersion = $availableVersions.version | Sort-Object -Descending | Select-Object -First 1 -ExpandProperty Value

Write-Host "Stage and install latest version" -BackgroundColor Yellow
$userData = $updateService.help.stage_and_install.user_data.Create()
$userData.add('id', $latestVersion)
$updateService.stage_and_install($latestVersion,$userData)
Reply
0 Kudos
LucD
Leadership
Leadership

You could use Start-Job to launch multiple instances of your script, each handling a different VCSA.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
lElOUCHE_79
Enthusiast
Enthusiast

Ok, there's no way for a loop and import VCSA list via TXT file?

Reply
0 Kudos
LucD
Leadership
Leadership

That is exactly what I mean.
Loop over all VCSA, and for each VCSA use Start-Job to launch your script.
Have a look at my Running a background job post to see how to handle the Connect-VIServer inside the Start-Job code.




Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

lElOUCHE_79
Enthusiast
Enthusiast

would you please guide me?

I'm not sure where shall I add my script into the function Running a background job 

Reply
0 Kudos
LucD
Leadership
Leadership

Your script should go into the $code variable.
But make sure that you pass the correct SessionId as a parameter on the Start-Job cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference