PowerCLI: Update the BIOS of all G10 server in a vSphere environment

So we need to update all G10 servers which reside in a cluster.

I should mention we need to install ilorest in order to be able to that.

Then I have provided the process here:

ESXi Root HPE iLO Username & Password

$ilousername = 'ILOUSER'
$ilopassword = 'ILOPASS'

vCenter and Cluster Name

$Vcenter = "VC_ADDRESS"
$Cluster = "CLUSTER_NAME"

Getting all hosts on the specified cluster which their states are connected

Connect-VIServer $Vcenter
$Hosts = Get-Cluster -Name $Cluster |
Get-VMHost |
Where {$_.ConnectionState -eq "Connected"}

These tasks will be run on each hosts

foreach ($vihost in $Hosts) {

Putting Host into MaintenanceMode (DRS needs to be enabled)

Write-Host -Object "Entering $vihost into MainenanceMode" -ForegroundColor Cyan
Get-VMHost -Name $vihost | set-vmhost -State Maintenance -Evacuate | Out-Null

Getting iLO IP address, Uploading

Write-Host -Object "Update BIOS on $vihost" -ForegroundColor Cyan
$esxcli = Get-EsxCli -VMhost $vihost -V2
$HPServer = $esxcli.hardware.ipmi.bmc.get.Invoke() | Select -ExpandProperty "IPv4Address"
Write-Host -Object "iLO IP is $HPServer" -ForegroundColor Cyan

Updating BIOS with iLOrest

You need to specify iLOREST and BIOS fwpkg file location

cd "C:\Program Files\Hewlett Packard Enterprise\RESTful Interface Tool\"
.\ilorest.exe login $HPServer -u $ilousername -p $ilopassword
.\ilorest.exe fwpkg C:\G10\BIOS\I41_2.76_02_09_2023.fwpkg
Start-Sleep -s 5

Reboot Host

Write-Host -Object "Rebooting ESXi $vihost" -ForegroundColor Cyan
Get-VMHost -Name $vihost | Restart-VMHost -Confirm:$false | Out-Null
Start-Sleep -s 300

Exiting Host from MaintenanceMode

Write-Host -Object "Exiting $vihost from MainenanceMode" -ForegroundColor Cyan
Get-VMHost -Name $vihost | set-vmhost -State Connected | Out-Null
}
Disconnect-VIServer -Server * -Force

About admin

Check Also

PowerCLI: how to get unreserved CPU and Memory resource for each ESXi host?

I had reservation for some VMs in clusters, I wanted to find out how much …

Leave a Reply

Your email address will not be published. Required fields are marked *