Automation

 View Only
  • 1.  Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 05:58 AM

    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}}

     



  • 2.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 07:28 AM

    And what is the issue with that code?



  • 3.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 08:15 AM

    Thanks Lucd for reply.. 

    no error. it slilently exit from the script.. 

    No action perfomed. 



  • 4.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 10:35 AM

    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



  • 5.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 10:47 AM

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

     



  • 6.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 10:49 AM

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



  • 7.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 12:03 PM

    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
    }
    }



  • 8.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 12:12 PM

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



  • 9.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 12:27 PM

    Yes. Same baseline need to update all vcenters. 

    Any better improve script.  ?

     



  • 10.  RE: Update esxi patdch for multiple vc hosts.

    Posted Feb 24, 2023 12:32 PM

    No, not really