VMware Cloud Community
sivagndl
Enthusiast
Enthusiast

Update esxi patdch for multiple vc hosts.

Hi team,

How to update multiple hosts patching using below code. 

 

connect-viserver vc1,vc2,vc3

$basechk=Get-Baseline -Name "Baselinename"
foreach ($ho in Get-VMHost (Get-Content hostlist.txt)){
foreach($ho1 in get-vmhost $ho){
Remediate-Inventory -Entity $ho1 -Baseline $basechk -ClusterDisableHighAvailability:$true -Confirm:$false -ErrorAction SilentlyContinue -RunAsync}}

 

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership

And what is the issue with that code?


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

Reply
0 Kudos
sivagndl
Enthusiast
Enthusiast

Thanks Lucd for reply.. 

no error. it slilently exit from the script.. 

No action perfomed. 

Reply
0 Kudos
LucD
Leadership
Leadership

Due to the RunAsync switch, it is normal that it silently exits.

But you should see the Tasks running, with Get-Task or in the Web GUI


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

Reply
0 Kudos
sivagndl
Enthusiast
Enthusiast

No Lucd,, Not running any task.. i have cheacked it. 

 

Reply
0 Kudos
LucD
Leadership
Leadership

Leave out the RunAsync switch and see if any errors are returned.


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

Reply
0 Kudos
sivagndl
Enthusiast
Enthusiast

i tryed like below , its working as expected. 

impored csv file with Host name and vcenter

foreach ($ho in import-csv hostlist.csv) {
foreach($ho1 in get-vmhost -name $ho.name ) {
Remediate-Inventory -Entity $ho1.name -Baseline (Get-Baseline -Name "ADP-6.7-Dell-dec2022" -server $ho.vcenter) -ClusterDisableHighAvailability:$true -Confirm:$false -ErrorAction SilentlyContinue -RunAsync
}
}

Reply
0 Kudos
LucD
Leadership
Leadership

So you have Baselines with the same name in multiple vCenters?


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

Reply
0 Kudos
sivagndl
Enthusiast
Enthusiast

Yes. Same baseline need to update all vcenters. 

Any better improve script.  ?

 

Reply
0 Kudos
LucD
Leadership
Leadership

No, not really


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