You are on page 1of 7

Reset ESXi 6 Evaluation License (cron script included) | Calvin Bui https://calvin.

me/reset-esxi-evaluation-license/

Calvin Bui
Home Topics Donate

Reset ESXi 6 Evaluation License (cron script included)


Thursday, 17 December 2015 • How-To   • Virtualisation

For testing and educational purposes only

The ESXi 6 evaluation license is valid for 60 days and a free one can be obtained from
VMware at anytime. Resetting the evaluation license provides continual access to all the
features available, and most importantly for me, full compatibility with the ESXi Embedded
Host Client.

Commands

1 of 7 7/2/2018, 3:02 PM
Reset ESXi 6 Evaluation License (cron script included) | Calvin Bui https://calvin.me/reset-esxi-evaluation-license/

Note: Running these commands will cause ESXi to appear offline/down. For example, my
UPS virtual machine connected to my actual UPS began shutting down VMs because it
believed ESXi ran into a problem. Shut down those VMs firstly before running this
command then bring them back up later.

Turn on SSH and log in to the host.

Remove the current license

1 $ rm -r /etc/vmware/license.cfg

Copy over the new evaluation license, which is already on the host

1 $ cp /etc/vmware/.#license.cfg /etc/vmware/license.cfg

Restart ESXi services

1 $ /etc/init.d/vpxa restart

Confirm the new license

Automatic Script

The commands above can be run automatic to keep your ESXi license reset on a set
schedule using cron.

I have also created a script which powers off and on a VM of your choice (such as a UPS
agent) in case it shuts down the host.

First create the script (reset-eval.sh) somewhere accessible to ESXi. I chose to put in my
ZFS0 datastore (/vmfs/volumes/ZFS0/reset.eval)

1 #!/bin/sh

2 of 7 7/2/2018, 3:02 PM
Reset ESXi 6 Evaluation License (cron script included) | Calvin Bui https://calvin.me/reset-esxi-evaluation-license/

2 ## remove license
3 echo 'Removing License'
4 rm -r /etc/vmware/license.cfg
5 ## get a new trial license
6 echo 'Copying new license'
7 cp /etc/vmware/.#license.cfg /etc/vmware/license.cfg
8 ## restart services
9 echo 'Restarting VPXA'
10 /etc/init.d/vpxa restart

This alternative script shuts down any VM called ‘ups-agent’. You may edit that line to your
VM’s name

1 #!/bin/sh
2
3 # This script shuts down the UPS-Agent and resets the license
4 echo 'Getting VMID of UPS-Agent'
5 vmid=$(vim-cmd vmsvc/getallvms | grep ups-agent | awk '{print $1}')
6 echo 'VMID is' $vmid
7
8 echo 'Getting UPS-Agent Power state'
9 state=$(vim-cmd vmsvc/power.getstate $vmid | grep Powered)
10 echo 'VM is currently' $state
11 x=1
12
13 while [[ "$state" == "Powered on" && $x -lt 3 ]]
14 do
15 echo 'Powering off...'
16 vim-cmd vmsvc/power.shutdown "$vmid"
17 echo 'Waiting for VM to power off...'
18 i=30;while [ $i -gt 0 ];do if [ $i -gt 9 ];then printf "bb$i";else

3 of 7 7/2/2018, 3:02 PM
Reset ESXi 6 Evaluation License (cron script included) | Calvin Bui https://calvin.me/reset-esxi-evaluation-license/

19 state=$(vim-cmd vmsvc/power.getstate $vmid | grep Powered)


20 x=`expr $x + 1`
21 done
22
23 if [ "$state" == "Powered off" ]
24 then
25 ## remove license
26 echo 'Removing License'
27 rm -r /etc/vmware/license.cfg
28 ## get a new trial license
29 echo 'Copying new license'
30 cp /etc/vmware/.#license.cfg /etc/vmware/license.cfg
31 ## restart services
32 echo 'Restarting VPXA'
33 /etc/init.d/vpxa restart
34 #echo 'Restarting Services'
35 #services.sh restart
36 ## power on
37 echo 'Powering on USP-Agent'
38 vim-cmd vmsvc/power.on "$vmid"
39 else
40 echo 'Could not turn off UPS-Agent'
41 fi
42
43 echo 'Finished'

Test the script and make sure it works (remember to chmod +x)

1 $ chmod +x reset-eval.sh
2 ./reset-eval.sh

4 of 7 7/2/2018, 3:02 PM
Reset ESXi 6 Evaluation License (cron script included) | Calvin Bui https://calvin.me/reset-esxi-evaluation-license/

Add the script to the crontab to make it run on a set schedule (mine is set at 6:05am each
day). For each 59 days do ‘* * 59 * *’

1 /bin/echo "5 6 * * * /vmfs/volumes/ZFS0/reset-eval.sh" >> /var/spool/cron/crontabs/


2 kill $(cat /var/run/crond.pid)
3 crond

Finally add the following to the end of ‘/etc/rc.local.d/local.sh’ to regenerate the job as ESXi
clears the crontab on reboot

1 $ /bin/kill $(cat /var/run/crond.pid)


2 $ /bin/echo "5 6 * * * /vmfs/volumes/ZFS0/reset-eval.sh" >> /var/spool/cron/crontab
3 $ crond

5 of 7 7/2/2018, 3:02 PM
Reset ESXi 6 Evaluation License (cron script included) | Calvin Bui https://calvin.me/reset-esxi-evaluation-license/

28 Comments calvin.me 1 Login

Recommend 8 Share Sort by Newest

Join the discussion…

LOG IN WITH
OR SIGN UP WITH DISQUS ?

ginettanyk • 4 months ago


I replace the license as shown above, but I only have disconnect, remove then add back to
vcenter to reflect the changes.
• Reply • Share ›

Sam ginettanyk • 4 months ago


have you figure this out yet? i have same issue
• Reply • Share ›

ginettanyk Sam • 4 months ago


See my response.
It works.

Replace the licence file using the .#license file (see above for filename and
location). All I did was remove the host from vcenter and readd it. All works and no
reboot needed.
ginettanyk
• Reply • Share ›

pemmaraju5 • a year ago


This is great. Do I need to select "Public Evaluation" version of vSphere while downloading?
http://www.vmware.com/try-v...
• Reply • Share ›

Milton Garcia • a year ago


It works great, but not need shutdown vm, just suspend and working too, short time to start ....
Thanks!!!!
• Reply • Share ›

Agha Ali • a year ago


It works Great....Thanks
• Reply • Share ›


6 of 7 7/2/2018, 3:02 PM
Reset ESXi 6 Evaluation License (cron script included) | Calvin Bui https://calvin.me/reset-esxi-evaluation-license/

© 2018 Calvin Bui | Back to Top

7 of 7 7/2/2018, 3:02 PM

You might also like