Skip to main content
Question

Worket to Upgrade VMware tools

  • December 1, 2022
  • 4 replies
  • 369 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?

4 replies

Forum|alt.badge.img

Did you ever write one?


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

Im interested in this as well

 


Forum|alt.badge.img
  • Novice
  • 19 replies
  • 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
  • 129 replies
  • 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.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings