VMware Cloud Community
sravas
Contributor
Contributor

upgrade VMware tools programatically

Hi , I want to upgrade VMware tools programatically.

VMware tools is installed in the guest OS but can be managed from vCenter. Updates are usually manual.

Does this method UpgradeTools_Task will help us in this regard ? or How to achieve this using programatically if you give me some steps that will be a great help.

 

0 Kudos
2 Replies
DavoudTeimouri
Virtuoso
Virtuoso

Hi,

You can upgrade VMware Tools on single/multiple VMs via PowerCLI.

See my old blog post as an example: https://www.teimouri.net/update-vmware-tools-automatically/

-------------------------------------------------------------------------------------
Davoud Teimouri - https://www.teimouri.net - Twitter: @davoud_teimouri Facebook: https://www.facebook.com/teimouri.net/
0 Kudos
sravas
Contributor
Contributor

Hi @DavoudTeimouri 

Thanks for the reply.

 try {
            Task task = vm.upgradeTools_Task("installerOptions => qq|/S /v \"/qn REBOOT=R ADDLOCAL=ALL REMOVE=Hgfs\"|")

            TaskInfoState taskState = vsphereTaskRunner.run(task)

            if (taskState != TaskInfoState.success) {
                log.trace('vsphere-task': task.MOR.val, 'vsphere-task-state': taskState.toString(), "Task is not successful")
                throw new Exception("Vsphere Task ${task.MOR.val} is in state: ${taskState} (and not success)")
            }
        }
        catch (Exception e) {
            log.error("encountered ${e.class} when attempting to update vmware tools")
            throw new ProvisioningException("Could not reconfigure VM when attempting to change the ServiceNet portgroup to ${portGroupName} on device ${deviceId}")
        }

 The above code snippet am using to resolve my issue. No manual intervention with the VM in my case.

But this is giving error vix error code = 21009 

Do I need to add anything else 

0 Kudos