Upgrading VMware Tools on each ESXi Host via ESXCLI
- Ben Liebowitz
- 0
- 2766
Have you ever wanted to upgrade the version of VMware Tools on your hosts but you’re having an issue with Update Manger/Lifecycle Manager? I ran into this problem recently. I was attempting to upgrade my hosts to the latest version of VMware Tools and even though the remediation completed successfully via Lifecycle Manger finished successfully, each host still reported at the old Tools version. While I didn’t have time to delve into the logs, I decided to find another way.
First, lets talk about how to find the current version of tools that’s installed on each of your VMware Hosts.
# Get the VMHosts in your Cluster and sort by Name
$VMhosts = Get-Cluster LAB | Get-VMhost | Sort Name
# Loop through each VMHost
foreach ($VMhost in $VMhosts) {
# Get ESXCLI for each VMhost
$esxcli = Get-EsxCli -VMHost $VMhost -V2
# Display the host we're checking the version on
Write-Host "Getting VMware Tools version for $VMhost"
# Get the VMware Tools version
$esxcli.software.vib.list.invoke() | Where {$_.Name -match "tools"}
}
So as you can see here, each of my lab hosts are running VMware Tools version 12.2.0. The newest version is version 12.3.0. Lets go through the process of upgrading each host!
First step is to upload the offline VIB to one of your datastores. I only have 3 datastores in my lab environment. Two are SATA and one is SSD. I created a scratch folder on Datastore1 and uploaded the VIB there.
Now that the VIB is uploaded, I assigned a variable VIBPATH to that location. Then, I was able to loop through each VMHost and upgrade VMware Tools!
$vibpath = "/vmfs/volumes/Datastore1/Scratch/VMware-Tools-12.3.0-core-offline-depot-ESXi-all-22234872.zip"
# Lets loop through each VM Host again
foreach ($VMhost in $VMhosts) {
# Display which host we're upgrading
Write-Host "Preparing $VMhost for ESXCLI" -ForegroundColor Yellow
# Get ESXCLI for each VMhost
$esxcli = Get-Esxcli -VMHost $VMhost -v2
# Install VIBs
Write-Host "Installing VIB on $VMhost" -ForegroundColor Yellow
$action = $esxcli.software.vib.install.invoke(@{depot=$vibpath})
# Install VIB & Verify it installed successfully. If not, display error
if ($action.Message -eq "Operation Finished Successfully.")
{write-host "Action completed successfully on $VMhost" -ForegroundColor Green}
else {write-host $action.message -ForegroundColor Red}
}
If the VIB is already installed, you may see the message “HOST IS NOT CHANGED.”
Now, lets verify again and see that each host is on 12.3.0.
Ben Liebowitz, VCP, vExpert
NJ VMUG Leader