VMware Cloud Community
Mallik7
Enthusiast
Enthusiast

I want to upgrade vmtools version along with vm hardware version with a powerCLI script. Is that possible, if yes, can some one help here?

This is how I'm planning to do -

I'm going to install vmware tools version 10.1.10 by calling a exe setup file from a folder. If I use the default vmware tools install option, vmtoosl version 10.1.5 will get installed which I don't want. Hence, the requirement would be like below -

First will install the vmtools and then reboot the server.

Once vmtools version is up to date, now shutdown the server and update vm hardware version to the latest.

Script should be able to handle the errors like if any server, not found, should say, not found / not reachable / some other error. Error handing should be available.

Can some one help here. Thanks in advance.

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

The VMware Tools can be upgraded with the Update-Tools cmdlet, and a reboot with the Restart-VMGuest cmdlet.

For a HW version version upgrade have a look at Re: Hardware Version Upgrade

Not sure what you mean by this error handling.
Do you have a list of VM displaynames, and is it possible some of these VMs do not exist, or are not powered on?

Please explain.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
virtualDD
Enthusiast
Enthusiast

A while back I wrote a script to upgrade VMware Tools und the VM version (virtual hardware). This can be found here: https://virtualfrog.wordpress.com/2017/07/24/powercli-automating-vmware-tools-and-hardware-upgrades/

It has some basic error handling, but it's not really clear what you are looking for based on your description.

If you don't want to use the tools version that is shipped with your ESXi build you can customize the place where the ESXi hosts gets its' tools from.

Here is the function that does this in my kickstart script:

SetVMwareToolsCustomLink()

{

    #Replace the Symlink on the /productlocker to point to a different location

    datastore=$1

    if [ ! -z $datastore ]; 

        then

        

        if [ -d $datastore/floppies ] && [ -d $datastore/vmtools ]

            then

                /bin/ln -sfn $datastore /productLocker

                esxcli system settings advanced set -o "/UserVars/ProductLockerLocation" --string-value="$datastore"

            fi

    fi 

}

SetVMwareToolsCustomLink()
{
    #Replace the Symlink on the /productlocker to point to a different location
    datastore=$1
    if [ ! -z $datastore ]; 
        then
        
        if [ -d $datastore/floppies ] && [ -d $datastore/vmtools ]
            then
                /bin/ln -sfn $datastore /productLocker
                esxcli system settings advanced set -o "/UserVars/ProductLockerLocation" --string-value="$datastore"
            fi
    fi 
}
Reply
0 Kudos
RAJ_RAJ
Expert
Expert

For Specific VM - >   get-vm VMNAME | Update-Tools -NoReboot

Update All Vms ->     get-vm | Update-Tools -NoReboot

Hardware Version - >  Set-Vm -VM (Get-VM -Name [VM-NAME]) -Version v[HW-VERSION]

RAJESH RADHAKRISHNAN VCA -DCV/WM/Cloud,VCP 5 - DCV/DT/CLOUD, ,VCP6-DCV, EMCISA,EMCSA,MCTS,MCPS,BCFA https://ae.linkedin.com/in/rajesh-radhakrishnan-76269335 Mark my post as "helpful" or "correct" if I've helped resolve or answered your query!
Reply
0 Kudos