By default the VMware Tools upgrade policy is disabled and set to "manual" mode. If you want the vSphere platform to automatically check and upgrade VMware Tools upon a system power cycle, then you can enable it by going to Edit VM->Options->Tools->Check and upgrade Tools during power cycling.
To update this configuration, there is a property in the vSphere API called toolsUpgradePolicy which can accept two values: manual or upgradeAtPowerCycle.
Here is a vSphere SDK for Perl script updateVMToolsPolicy.pl that supports two types of operations: "list" and "update". The list operation will show you all VMs and their currently configured upgrade policy, by default they should be all manual unless you have changed it manually. The update operation will allow you to configure a list of VMs and policy you designate. This change can be done while the VM is running, you do not need to make any changes to the guestOS that is running.
Here is an example of the "list" operation:
If you want to take all the VMs that have "manual" policy and change them over to "upgradeAtPowerCycle", you can copy the output to a file and then use a find or UNIX/Linux grep command to search for entries that have the word "manual".
Here is the command you can use if you are on a UNIX/Linux system:
cat output | grep "manual" | awk -F '["|"]' '{print $2}'
Here is the command to get the first column which contains the VM display name:
cat output | grep "manual" | awk -F '["|"]' '{print $2}' > VMLIST
Lastly, you just need to take the previous command and redirect that to a file which will then be used in the "update" operation. You can also take the output and using an editor to get to the final output, use whatever you are comfortable with.
Here is an example of the commands listed above:
Now that we have the list of VMs we are interested in updating, we just need to select the policy and perform the "update" command. Here is an example:
So there you have it, you can now easily automate the the VMware Tools upgrade policy for any or all your VMs without having to edit each one manually.













You William, are a star, thank you very much indeed.
ReplyDelete@Chopper3,
Deletenp, glad I could help
Another awesome post and script. Many thanks!
ReplyDelete@John,
ReplyDeletenp! and thanks for the comment
This comment has been removed by the author.
ReplyDeleteHere is the PowerCLI version to set VMTools to "UpgradeAtPowerCycle":
ReplyDelete$vms = Get-VM | where {(Get-Cluster).Name -eq "CLUSTER NAME"}
Foreach ($vm in $vms) {
$config = New-Object VMware.Vim.VirtualMachineConfigSpec
$config.Tools = New-Object VMware.Vim.ToolsConfigInfo
$config.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
$vm.ExtensionData.ReconfigVM($config)
}
Cheers