← script library
Batch Updating VMware Tools on Multiple VMs with PowerShell
VMware & vSphereJanuary 6, 2025
Keeping VMware Tools updated on all your virtual machines is crucial for optimal performance and compatibility. This PowerShell script automates the process of updating VMware Tools on multiple VMs in your environment, ensuring they are running the latest version. This not only reduces manual effort but also enhances the performance and stability of your virtual machines.
powershell
# Load VMware PowerCLI module
Import-Module VMware.PowerCLI
# Connect to the vSphere server
$vCenterServer = "your_vcenter_server"
$username = "your_username"
$password = "your_password"
Connect-VIServer -Server $vCenterServer -User $username -Password $password
# Define a list of VMs for updating VMware Tools
$vmNames = @("VM1", "VM2", "VM3") # Replace with the names of your VMs
# Update VMware Tools on each VM
foreach ($vmName in $vmNames) {
$vm = Get-VM -Name $vmName
if ($null -ne $vm) {
$toolsStatus = $vm.ExtensionData.Guest.ToolsVersionStatus2
if ($toolsStatus -eq "toolsOld" -or $toolsStatus -eq "toolsNotInstalled") {
Write-Host "Updating VMware Tools on $vmName..."
Update-Tools -VM $vm -Confirm:$false
Write-Host "VMware Tools updated for $vmName."
} else {
Write-Host "VMware Tools are up to date on $vmName."
}
} else {
Write-Host "VM $vmName not found."
}
}
# Disconnect from the vSphere server
Disconnect-VIServer -Server $vCenterServer -Confirm:$falseRun it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in VMware & vSphere
Ready when you are.
Try ServerEngine free for 7 days.