VMware Tools Upgrade Policy/Settings

For the past couple weeks I have been using a nice one-liner to find out the VMs in my environment have the upgrade policy that I want them to have. I almost always personally want my virtual machines to upgrade vmware tools on a powercycle. It makes it easier for me, and just one less thing that I have to worry about.

The two possible setting for the vmware tools upgrade policy are: Manual, and UpgradeAtPowerCycle.

get-vm|?{(get-vm $_ |get-view).config.tools.toolsupgradepolicy -notlike “*powercycle”}

Granted it isn’t the prettiest one-liner but it gets the job done. I like the upgradeatpowercycle setting so in my one-liner I searching for all the ones that are NotLike UpgradeAtPowerCycle, in order for me to go in and change their settings. You can also quickly adapt this one-liner if you just want to inspect the VMs inside of a particular folder or datacenter etc..

If you happen to find several VMs you want to change the settings on, here is a script just for you. Now I don’t remember the exact place I originally found this script, but there are all kinds of variations of this one on those darn interwebs. This one is even slightly personalized to my tastes…

param([string]$servers)

$spec= new-object vmware.vim.virtualmachineconfigspec
$spec.tools=new-object vmware.vim.toolsconfiginfo
$spec.tools.toolsupgradepolicy ="upgradeatpowercycle"

$vms= get-vm $servers
Foreach($vm in $vms){
$view=$vm|get-view
$view.reconfigvm($spec)
}

The super duper neato thing you can then do is assign that one liner to a variable, then just use that variable as the input parameter for the script. Then you have just changed hundreds of thousands of virtual machines’ upgrade settings with little or no work.

Three cheers for you!

Let me know what you think or if you have any questions!

Leave a Reply