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}}
And what is the issue with that code?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Lucd for reply..
no error. it slilently exit from the script..
No action perfomed.
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
No Lucd,, Not running any task.. i have cheacked it.
Leave out the RunAsync switch and see if any errors are returned.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
}
}
So you have Baselines with the same name in multiple vCenters?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes. Same baseline need to update all vcenters.
Any better improve script. ?
No, not really
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
