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.

update vmtools automatically

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 
        Write-Output “Completed”

Davoud Teimouri

Professional blogger, vExpert 2015/2016/2017/2018/2019/2020/2021/2022/2023, vExpert NSX, vExpert PRO, vExpert Security, vExpert EUC, VCA, MCITP. This blog is started with simple posts and now, it has large following readers.

Leave a Reply

Your email address will not be published. Required fields are marked *