Update VMware Tools Automatically
Oh, VMware released a critical patch or new vSphere version, you need to upgrade your environment. Your environment is upgraded but VMware recommended that keep VMware Tools updated on your virtual machines, so you have to update.
How do you update VMware tools? Using vSphere client, PowerCLI or … .
Best way is enable a settings in virtual machine settings, “Check and upgrade Tools during power cycling”. But you need to check it on every VM.
You can use this script for enable that on all Windows virtual machines in vCenter.
Get-VM | Get-View | ForEach-Object{ Write-Output $_.name if ($_.config.tools.toolsUpgradePolicy -ne “upgradeAtPowerCycle” -and $_.Guest.GuestFamily -match “windowsGuest”){ $vm = Get-VM -Name $_.name $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.changeVersion = $vm.ExtensionData.Config.ChangeVersion $spec.tools = New-Object VMware.Vim.ToolsConfigInfo $spec.tools.toolsUpgradePolicy = “upgradeAtPowerCycle” $_this = Get-View -Id $vm.Id $_this.ReconfigVM_Task($spec) Write-Output “Completed” } }