Recently, I wanted to upgrade a vSphere 7 non vSAN cluster to version 8 with a single image. During the compliance check it turned out that all hosts in the cluster were not compliant and therefore the upgrade could not be started. The following error was displayed.
There appeared to be two VIBs installed that were not supported. On the host’s commandline, I looked up the names of VIBs and noted them. The VIBs involved in this case were the following:
- nenic
- iavmd
These will be needed later in the Powershell script.
Since I don’t want to log into every server and then have to delete the VIBs via the CLI, I created the following script. I would like to thank my colleague Kabir very much for his time, explanation and mentoring. He has great scripting and automation skills and has written great articles that you can find here, whatkabirwrites.nl
Back to the script. The script removes the two VIBs on all hosts in a cluster. Before using the script be sure that the VIBs are not used. The following steps are performed by the script:
- Host is put into maintenance mode
- Check if VIBs are installed
- If present, they are removed
- Host is rebooted
- Host goes out of maintenance mode
- Next host
If a host is already in maintenance mode, it will remain in maintenance mode after the reboot.
At the top of the script, the Remove VIBs function is defined. Adjusting the setting $settings.dryrun = $true to $false really removes the VIBs. Without adjusting this, the VIBs are not removed and only verified to be present or not. Regardless of the value of $settings.dryrun = $true or $false the hosts are always put into maintenance mode and rebooted.
After executing the host reboot, the script waits 4 minutes before continuing. I built in this pause because nested ESXi hosts reboot so quickly that otherwise the script won’t enter or exit the wait loop. I have used the script in a test lab and it works very well.
Please be aware that using this script is at your own risk!
#Pre-Upgrade script ESXi7 to ESXi8 #This script remove vibs on all hosts in a cluster that blocks the upgrade # Function Remove VIBs function RemoveVIB { Param ( $ESXi # The EsxCli object ) [array]$arrayvibs = @("nenic", "iavmd") $esxcli = Get-EsxCli -V2 -VMHost $ESXi foreach ($vib in $arrayvibs) { if ($esxcli.software.vib.list.Invoke() | where {$_.Name -eq "$VIB"}) { $settings = $esxcli.software.vib.remove.CreateArgs() $settings.dryrun = $true $settings.vibname = "$VIB" echo "$VIB VIB found, remove VIB $esx" $esxcli.software.vib.remove.Invoke($settings) } else { echo "No $VIB VIB found $esx" } } } # vCenter & Cluster Parameters $vCenter = "FQDN vCENTER" $cluster = "Cluster Name" # Connect vCenter Try {Disconnect-VIServer * -Confirm:$false -ErrorAction SilentlyContinue | out-null} Catch {} Connect-VIServer $vCenter $ESXis= Get-Cluster -Name $cluster| Get-VMHost | sort Name | where {$_.ConnectionState -eq 'Connected' -or $_.ConnectionState -eq 'Maintenance'} foreach ($ESXi in $ESXis) { write-host "Working on host $($esxi)" # Host status is Maintenance Mode if ($ESXi.ConnectionState -eq 'Maintenance') { Write-host "Host is already in Maintenance Mode..." RemoveVIB -ESXi $ESXi Write-host "Host Reboot in Maintenance Mode..." write-host "Herstarten host $($esxi)" Restart-VMHost -VMHost $ESXi -Confirm:$False | Out-Null write-host "Waiting 4 minutes to make sure the host is disconnected before proceeding..." start-sleep 240 $hoststat = (Get-VMHost -Name $ESXi.Name) While ($hoststat.ConnectionState -eq "NotResponding") { Write-host "Host is still rebooting... waiting 10sec..." Start-Sleep 10 $hoststat = (Get-VMHost -Name $ESXi.Name) } } #Host status is not Maintenance Mode else { Write-Host "$($ESXi) is not in Maintenance Mode. Put host in Maintenance Mode..." write-host "" # Host in Maintenance Mode Set-VMHost -VMHost $ESXi -State Maintenance -Confirm:$False | Out-Null # Vib Remove RemoveVIB -ESXi $ESXi # Host Reboot Write-host "Host is in Maintenance Mode" write-host "Reboot host $($esxi)" Restart-VMHost -VMHost $ESXi -Confirm:$False | Out-Null write-host "Waiting 4 minutes to make sure the host is disconnected before proceeding..." start-sleep 240 $hoststat = (Get-VMHost -Name $ESXi.Name) While ($hoststat.ConnectionState -eq "NotResponding") { Write-host "Host is still rebooting... waiting 10sec..." Start-Sleep 10 $hoststat = (Get-VMHost -Name $ESXi.Name) } # Host uit MM write-host "Reboot on host $($esxi) is completed..." write-host "" Start-Sleep 20 Set-VMHost -VMHost $ESXi -State Connected -Confirm:$False | Out-Null } write-host "Done on host $($esxi)" write-host "" } #Disconnect vCenter write-host "Disconnecting vCenter $vCenter" Disconnect-VIServer -Confirm:$False | Out-Null