Today I got a question on how you can change the “Tools Upgrades” settings through vRO:

After this setting is enabled VMware Tools version for a VM will be checked and upgraded during a power on or reboot. You can change this setting through vRO using just a few lines of code:
System.log ("Current Tools Upgrades configuration : " + vm.config.tools.toolsUpgradePolicy);
if (vm.config.tools.toolsUpgradePolicy!="upgradeAtPowerCycle") {
var configSpec = new VcVirtualMachineConfigSpec();
var toolsSpec = new VcToolsConfigInfo();
toolsSpec.toolsUpgradePolicy = "upgradeAtPowerCycle";
configSpec.tools = toolsSpec;
var task = vm.reconfigVM_Task(configSpec);
System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,true,2);
System.log ("Changed Tools Upgrades configuration: " + vm.config.tools.toolsUpgradePolicy);
}
else System.log ("Nothing to do!");
This script expects a VC:VirtualMachine object (‘vm’) as input parameter. You can both use this script as in day 2 operations in vRA, or as link it to the event broker at make it part of the initial deployment.
Happy coding!



