Chris Hall bio photo

Chris Hall

Principal Technical Consultant

PolarCloudsUK Chris LinkedIn Github
Chris Hall Nutanix Certified Master - Multicloud Infrastructure 6 Chris Hall VMware vExpert 2023 Chris Hall VMware vExpert NSX 2023 Chris Hall Nutanix Certified Professional - Multicloud Infrastructure 6 Chris Hall Nutanix Certified Professional - Unified Storage 6 Chris Hall VMware vExpert 2022 Chris Hall VMware vExpert 2021

NSX-T Logo In observance of National Lazy Day 2022… Yeah I know, it was 5 days ago… But hey, who’s counting?

Back when, VMtools used to be updated with each ESXi patch installation. Just patch ESXi, an updated VMTools would be rolled in and away we go; VMs to update.

Not any more.

So what is the simplest way to handle VMTools updates?

Follows is the Lazy Guide.

Not that VM admins are lazy - far from it! VM admins have other things to do; Networking with NSX-T, Storage with vSAN, Compliance with vRO, Cloud Management with vCD, Disaster Recovery with SRM to name a few. You know, other stuff to be getting on with… :wink:

Overview

Overview

Other methods of updating VMtools are available such as the VMTools Repository Method, the Manual Method and the SCCM method.

Whilst those methods are okay, they do require either “getting down and dirty” with the vCenter/ESXi API (the repository method), lots of intervention (the manual method) or a System Center Configuration Manager (the SCCM method).

We are going to go simplicity. This method requires two steps:

  1. Update VMtools package via a baseline profile / update
  2. Configure VMs to auto update when a new version of VMtools is detected

As a bonus, we will look at achieving the above in both an enterprise deployment (I.E with vCenter Server(s)) and a smaller single host / stand-alone environment, without vCenter.

Finally, this post will take the form of a “beginners guide” with extra hand-holding and screenshots for those new to vSphere or unfamiliar with updating VMTools using these methods.

Download Latest VMTools

The permanent link to download VMtools is https://www.vmware.com/go/tools. For both with and without vCenter methods below, we require the VMware Tools Offline VIB Bundle.

With latest VMtools VIB in hand, lets get to it.

With vCenter Method

TL;DR - Import VIB, create a baseline, attach and remediate.

Import VIB + Create Baseline

From vCenter client (https://vcenter.fqdn/ui/), select Menu > Lifecycle Manager:

Open Lifecycle Manager Select Actions > Import Updates:

Import Updates

Select previously downloaded VMtools VIB and allow to upload:

Upload Update

Select Baselines > New > Baseline:

New Baseline

Enter Baseline name, description and select Patch:

New Baseline Details 1

Click Next.

Untick “Automatically update this baseline with patches that match the following criteria” and click Next:

New Baseline Details 2

Deselect “Show only rollup updates” and filter name on tools:

New Baseline Details 3

Select the version VMtools that matches your newly uploaded VMTools and ESXi versions. In my case below, I’m selecting VMTools version 12.0.6 and ESXi 7.0.*:

New Baseline Details 4

Click Next, confirm all looks correct and finally click Finish:

New Baseline Details 5

Yep all looks good:

New Baseline Details 6

Attach Baseline and Update Hosts

Select Menu > Inventory:

Open Inventory

As we want ALL ESXi hosts in our site to have the updated VMTools package, we will attach the baseline at our site level. Select your datacenter (in my case “SITE-A”), Updates and Baselines:

Site Baseline 1

Scroll down and select Attach Baseline or Baseline Group:

Site Baseline 2

Select the previously created VMTools baseline and click Attach:

Site Baseline 3

From the Inventory > Datacenter > Updates > Baselines view, select Check Compliance:

Remediate Hosts 1

Once the compliance check has completed, you will see that your hosts will be flagged as “Non-compliant”:

Remediate Hosts 2

Scroll down and select Pre-check Remediation:

Remediate Hosts 3

Confirm that there are no issues flagged that may prevent the completion of remediation:

Remediate Hosts 4

Click Done.

Scroll down further, select the VMTools package attached earlier and finally select Remediate:

Remediate Hosts 5

Again, confirm all looks goo and click Remediate again:

Remediate Hosts 6

Monitor the installation via Recent Tasks:

Remediate Hosts 7

Job Done:

Remediate Hosts 8

Giving ESXi ten minutes to catch up, yep our Windows VMs need updating:

Remediate Hosts 9

Don’t worry, I have a lazy way to handle those too. :wink:

Stand-alone ESXi (Without vCenter) Method

This method is a little simpler.

First off, we need to open our downloaded VMTools zip file and extract a VIB. Opening the zip and navigating into the vib20\tools-light folder, lets extract our VIB:

ESXi Update 1

Log onto the ESXi management interface (https://esxi.fqdn/ui/), select Storage and a Datastore. In my case I selected “LOCAL1”:

ESXi Update 2

Make a note of the location. This should be easily copied:

ESXi Update 3

Select Datastore browser and Upload. Select the VIB extracted earlier and click Open:

ESXi Update 4

Once the upload has completed, select Manage > Packages > Install Update:

ESXi Update 5

Using the location noted earlier, add the name of the VIB file, paste into the install update dialogue and select Update:

ESXi Update 6

Click Continue:

ESXi Update 7

Monitor and confirm successful completion:

ESXi Update 8

Finally, refresh the packages page, search for “tools-light” and confirm the updated version is listed:

ESXi Update 9

Again, giving ESXi ten minutes to catch up, yep our Windows VMs need updating:

ESXi Update 10

Installing VMTools in VMs

The simplest way to handle updating of VMTools in VMs is two-fold:

Linux and FreeBSD VMs

Use Open VM Tools for Linux and FreeBSD VMs rather than the VMware supplied VMTools. Open VM Tools are bundled with Linux and FreedBSD and are updated via distribution updates, therefore do not need updating separately. See Open VM Tools for details.

Windows VMs

Use automation. Lets look at that next.

Automating VMTools Updates (GUI Method - With vCenter)

If we dig into our Windows VMs and take a look at the Updates tab, we can see the following option to update VMtools automatically when a VM is rebooted:

VM Update 1

Since we are talking Windows based VMs here, we know that through normal maintenance patching, our VMs are rebooted at least once a month.

Lets configure auto VMTools auto update then. Select Site > VMware Tools:

VM Update 2

After selecting the Cluster and our Windows VMs, we can set auto update to On:

VM Update 3

Job done.

Automating VMTools Updates (GUI Method - Without vCenter)

Log into ESXi web client, select a Windows VM, Edit > VM Options, expand VMware Tools and enable Check and upgrade VMware Tools before each power on:

VM Update 4

Save and repeat for remaining Windows VMs.

Automating VMTools Updates (Script Method - Both With and Without vCenter)

The above methods VMTools Update methods are acceptable small scale, but what happens if we have hundreds of VMs to deal with?

Let’s use PowerShell! :sunglasses:

First let’s create a report of all Windows VMs that are not currently set to auto update VMTools:

Filename: Report-VMToolsAutoUpgrade.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$VC = @("vcenter.local")
$StoredCred = "vSphere-Admin"
$Report = "C:\Scripts\VM-Tools\V2\Enable-VMToolsAutoUpgrade-Report.csv"
$Credentials = Get-StoredCredential -Target $StoredCred
Connect-VIServer -Server $VC -Credential $Credentials
$UPGNeeded = Get-VM | Where {$_.ExtensionData.Config.Tools.ToolsInstallType -eq "guestToolsTypeMSI" -and `
                             $_.ExtensionData.Config.Tools.ToolsUpgradePolicy -like "manual" -and `
                             $_.ExtensionData.Config.ManagedBy.type -ne "placeholderVm" -and `
                             $_.Name -notlike "*FRED*"}
$UPGNeeded | Select-Object `
             Name,`
             PowerState,`
             @{label='Current Tools Version'; expression={($_.ExtensionData.Guest.ToolsVersion)}}, `
             @{label='Operating System'; expression={($_.Guest.OSFullName)}}, `
             @{label='VM Notes'; expression={($_.Notes[0..51] -join "")}} `
             | Export-Csv -Path "$Report" -NoTypeInformation
Write-Host "`n Report saved to $Report"
Disconnect-VIServer -Server * -Confirm:$false 

Breaking the report script down:

  • Lines 1 to 5: Configure and connect to vCenter / ESXi using Credential Manager as discussed in PowerShell Credential Handling post.
  • Lines 6 to 9: Select VMs where VMTools install like “guestToolsTypeMSI” (IE Windows VMs), where upgrade policy is like “manual”, where VM is not a SRM place holder VM and finally with a VM name not like “FRED”.
  • Lines 10 to 16: From the VMs selected, export name, power state, current tools version, guest operating system and VM notes (truncated to 50 characters).
  • Line 17: Export .csv report
  • Line 18: Disconnect from vCenter / ESXi

The above will create a .csv spreadsheet containing following information:

Name PowerState Current Tools Version Operating System VM Notes
APP1 PoweredOn 11334 Microsoft Windows Server 2016 (64-bit) Test Server APP1
APP2 PoweredOn 11334 Microsoft Windows Server 2016 (64-bit) Test Server APP2

Notice that the VM-CH-ESG-SITE-A is not listed in the report?

That’s because it’s a Linux VM running with Guest Managed VM tools:

Linux VM

After confirming the .csv spreadsheet contains the correct data, the next step is to enable VM tools on the applicable VMs. Again, we will use a script for this:

Filename: Enable-VMToolsAutoUpgrade.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$VC = @("vcenter.local") 
$StoredCred = "vSphere-Admin"
$Report = "C:\Scripts\VM-Tools\V2\Enable-VMToolsAutoUpgrade-Report.csv"
$Credentials = Get-StoredCredential -Target $StoredCred
Connect-VIServer -Server $VC -Credential $Credentials
$VMs = Import-CSV "$Report"
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
ForEach($VM in $VMs){ 
    Get-VM -Name $($VM.Name) | ForEach {$_.ExtensionData.ReconfigVM_task($vmConfigSpec) > $null}
    Write-Host "Reconfigured $($VM.Name)"
}
Disconnect-VIServer -Server * -Confirm:$false 

Breaking the enable script down :

  • Lines 1 to 5: Configure and connect to vCenter / ESXi using Credential Manager as discussed in PowerShell Credential Handling post.
  • Line 6: Import the report .csv
  • Lines 7 to 9: Create the VM configuration specification
  • Line 10 to 13: Loop through the .csv report and apply the configuration specification to each VM listed and feedback
  • Line 14: Disconnect from vCenter / ESXi

Let’s run the script:

Enabling VMTools Auto Update

Looks good. Checking one of the VMs reconfigured:

VMTools Auto Update Enabled

Boom!

After a reboot of the VM:

VMTools Auto Updating

Something to be aware of, sometimes VMs require a reboot to fully install VMTools:

VMTools Auto Reboot

If you are rebooting your VMs in a maintenance window, what difference does second reboot make anyway?

And we are done!

VMTools Upgrade Done

Conclusion and Wrap Up

So there we have it. A simple way to update VMTools using Baselines and Lifecycle Manager in vCenter if you have it, or via ESXi host VIB update if not.

We then looked at using the Open-VM-Tools package for Linux and FreeBSD based VMs.

Finally we looked at manual and scripted methods to configure VMs to auto update their VMTools installations when they are rebooted - say during a maintenance window.

All with ease. Happy belated Lazy Day 2022!

-Chris