Managing VMware Tools advanced options in PowerShell

Here is a quick way of selecting the VMware Tools Advanced option: “Check and upgrade Tools during power cycling” for all VMs in a cluster. Here is a screen shot of the option in question:

vmware_tools_upgrade

And here is the script:

$vms = get-cluster "Cluster Name" | get-vm

foreach($vm in $vms) 
{ 
$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)
}

Leave a Reply

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

5 × 5 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.