Skip to main content
Question

Worket to Upgrade VMware tools

  • December 1, 2022
  • 7 replies
  • 670 views

Afonso_Alves_31
Forum|alt.badge.img

Just checking if somebody here in the community created a worklet that upgrades vmware tools and works?

7 replies

Forum|alt.badge.img
  • Novice
  • January 23, 2024

Did you ever write one?


Forum|alt.badge.img+1
  • Rookie
  • February 6, 2024

Im interested in this as well

 


Forum|alt.badge.img
  • Novice
  • February 7, 2024

How about this.

 

# Function to update VMware Tools on a virtual machine
function Update-VMwareTools {
    param(
        [string]$VMName,
        [string]$vCenterServer,
        [string]$Username,
        [string]$Password
    )

    # Connect to the vCenter server
    Connect-VIServer -Server $vCenterServer -User $Username -Password $Password

    # Get the virtual machine object
    $VM = Get-VM -Name $VMName

    if ($VM) {
        # Check if VMware Tools is out of date
        if ($VM.ExtensionData.Guest.ToolsVersionStatus -eq "toolsOld") {
            # Update VMware Tools
            $Task = $VM | Update-Tools -NoReboot -RunAsync

            # Wait for the task to complete
            $Task | Wait-Task

            Write-Host "VMware Tools updated on $VMName"
        } else {
            Write-Host "VMware Tools on $VMName is already up to date"
        }
    } else {
        Write-Host "Virtual machine $VMName not found"
    }

    # Disconnect from the vCenter server
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false
}

# Usage example
Update-VMwareTools -VMName "YourVMName" -vCenterServer "YourVCenterServer" -Username "YourUsername" -Password "YourPassword"
 


Forum|alt.badge.img
  • Automox Employee
  • February 27, 2024

Hi Afonso,

I have been upgrading VMware tools like this:

This is just a Required Software policy since I find the Scope to be easier to use than the Evaluation code in a worklet. If a new Vmware tools version comes out, its easy enough to replace the installation file (from vmware) and increment the package version.

 

There is a way to trigger the update from within the host, but it depends on some Vsphere settings being in place to allow for it:

& "C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe" upgrade status
& "C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe" upgrade start

The ‘upgrade start’ command will not return anything into the Activity Log if its already at the latest version.


  • Rookie
  • May 7, 2025

Since the newer VMware tools installer have the c++ redistributables embedded how do you handle the reboots? 


Forum|alt.badge.img
  • Automox Employee
  • May 8, 2025

If the devices need a reboot after installing VMware tools I would just suggest using a Worklet, and make use of the Automatic Restart feature:
 

 


  • Rookie
  • June 19, 2025

Evaluation Code:

#Check if vmware-tools is installed
if ((choco list | select-string vmware-tools) -like "*vmware*") {$remediate += 1}

# Check for remediation
if($remediate)
{
Write-Output "vmware-tools IS installed - Flagging for Remediation"
Exit 1
}
Write-Output "vmware-tools NOT installed - Remediation not needed"
Exit 0

Remediation Code:

if ((choco list | select-string vmware-tools) -like "*vmware*") {choco upgrade vmware-tools -y}