WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Uncategorized / Automating VMware Tools Upgrade Policy

Automating VMware Tools Upgrade Policy

02.26.2012 by William Lam // 16 Comments

I received a question this week from a reader who was looking to change the VMware Tools upgrade policy for a few hundred virtual machines and wanted to know if it was possible to automate this. The answer is absolutely yes!

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.

More from my site

  • An update on how to retrieve useful information from a vSphere login?
  • Do I need to install both the vSphere CLI & vSphere SDK for Perl?
  • Automate Enabling VM Storage Profiles Capability in vSphere
  • Automating VCSA Network Configurations For Greenfield Deployments
  • Retrieving vscsiStats Using the vSphere 5.1 API

Categories // Uncategorized Tags // vsphere sdk for perl

Comments

  1. *protectedChopper3 says

    02/26/2012 at 5:48 pm

    You William, are a star, thank you very much indeed.

    Reply
    • *protectedWilliam says

      02/26/2012 at 5:58 pm

      @Chopper3,

      np, glad I could help

      Reply
  2. *protectedJohn Walsh says

    02/26/2012 at 6:09 pm

    Another awesome post and script. Many thanks!

    Reply
  3. *protectedWilliam says

    02/26/2012 at 6:12 pm

    @John,

    np! and thanks for the comment

    Reply
  4. *protectedDeanH says

    02/28/2012 at 3:59 pm

    This comment has been removed by the author.

    Reply
  5. *protectedDeanH says

    02/28/2012 at 4:01 pm

    Here is the PowerCLI version to set VMTools to "UpgradeAtPowerCycle":

    $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

    Reply
    • *protectedAnonymous says

      05/23/2013 at 11:05 pm

      Shouldn't the last line be this:

      $vm.ReconfigVM($config)

      Reply
  6. *protectedUKMAK says

    05/11/2012 at 12:50 pm

    Check and upgrade Tools during power cycling feature does not work in ESXi 5.0
    In ESX/ESXi 4.1, the Check and upgrade Tools during power cycling option was available to upgrade VMware Tools when the virtual machine shut down. This feature does not work in ESXi 5. Ignore any documentation procedures related to this feature.

    Workaround: Install VMware Tools manually.
    https://www.vmware.com/support/vsphere5/doc/vsphere-esx-vcenter-server-50-release-notes.html#vmissues

    Reply
  7. *protectedAnonymous says

    12/21/2012 at 6:12 pm

    Is there a way to automate Install VM Tools completely without human interaction by calling perl or java API? Now I am trying to do this but it seems the VM tools installer started but always popup a window to require clicking the "Next" button.

    Reply
    • *protectedWilliam says

      12/24/2012 at 8:06 pm

      Yes, there is a vSphere API to automate the installation of VMware Tools. The method you're looking for is UpgradeTools_Task() http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.VirtualMachine.html and this is the same operation if you were to right click and say Install/Upgrade VMware Tools and clicking next.

      Reply
    • *protectedAnonymous says

      01/03/2013 at 4:44 pm

      William, thanks for your reply.

      In http://pubs.vmware.com/vsphere-51/topic/com.vmware.ICbase/PDF/wssdk_prog_guide_5_1.pdf Page 130,
      UpgradeToolsTask – Performs an UPGRADE of VMware Tools. This method assumes VMware Tools has been installed and is running.

      What I need to do is automating INSTALL VM TOOLS. In order to install VM tools, I need to call the MountToolsInstaller( in Java) which does automatically start to run the VM tools installation program in the VM but this installation wizard pops up a window that requires human being click "Next" button in the VM otherwise the installation wizard just stays there forever.

      My question for you is: how can I fully automate the INSTALL VM tools operation without any human being interaction? or is it possible to do this? The ideal result would be the VM tools installed automatically in VM instead of requiring human being click the Next button in the VM.

      Reply
    • *protectedWilliam says

      01/04/2013 at 1:15 am

      If you call the MountToolsInstaller(), you can also pass in parameters for an unattended installation, you'll have to look up the options. I recommend you do this manually via CLI and then once you have all the flags, then you can pass that into your script which will perform the installation.

      Take a look at this VMware KB which includes some silent install flags which may help http://kb.vmware.com/kb/1018377

      Reply
    • *protectedAnonymous says

      01/04/2013 at 4:03 pm

      Thanks, William.

      The problem here is: in java MountToolsInstaller( ManagedObjectReference) only takes one parameter, the ManagedObjectReference of VM. There is no way to pass the option string into the MountToolsInstaller() in the java program.

      Reply
      • *protectedNitin says

        05/21/2018 at 10:43 am

        Hi,

        Were you able to install vmware tools automatically without any human being interaction.
        Can you please share steps to do so.

        Regards,
        Nitin

        Reply
    • *protectedWilliam says

      01/04/2013 at 4:15 pm

      I'm sorry, you're right, that's only valid for Upgrade method. The best method that I can see is basically mount up the ISO and then using the Guest Operations to perform the unattended installation (as you would from guestOS but using the CLI)

      Reply
  8. *protectedlazyvm says

    03/17/2016 at 1:13 am

    Thanks for the post William. I have a question
    I am seeing problem setting ¨upgradeAtPowerCycle¨ especially on database servers . A server reboot is happening right after the vmtools update and this is causing issue on SQL servers.My advice not to set this option on all VMs. Let me know if you got any other thoughts

    Reply

Leave a Reply to DeanHCancel reply

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

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025