{"id":6,"date":"2015-11-11T09:06:00","date_gmt":"2015-11-11T09:06:00","guid":{"rendered":"https:\/\/nguyenhieu.name.vn\/?p=6"},"modified":"2023-11-16T10:06:47","modified_gmt":"2023-11-16T03:06:47","slug":"reset-esxi-evaluation-license","status":"publish","type":"post","link":"https:\/\/nguyenhieu.name.vn\/?p=6","title":{"rendered":"How to reset ESXi 6 Evaluation License (cron script included)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">For testing and educational purposes only.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Commands<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Turn on SSH and log in to the host.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Remove the current license<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rm -r \/etc\/vmware\/license.cfg<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Copy over the new evaluation license, which is already on the host<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cp \/etc\/vmware\/.#license.cfg \/etc\/vmware\/license.cfg<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart ESXi services<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/init.d\/vpxa restart<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Confirm the new license<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Automatic Script<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The commands above can be run automatic to keep your ESXi license reset on a set schedule using cron.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First create the script (reset-eval.sh) somewhere accessible to ESXi. I chose to put in my ZFS0 datastore (\/vmfs\/volumes\/ZFS0\/reset.eval)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/sh\r\n## remove license\r\necho 'Removing License'\r\nrm -r \/etc\/vmware\/license.cfg\r\n## get a new trial license\r\necho 'Copying new license'\r\ncp \/etc\/vmware\/.#license.cfg \/etc\/vmware\/license.cfg\r\n## restart services\r\necho 'Restarting VPXA'\r\n\/etc\/init.d\/vpxa restart<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This alternative script shuts down any VM called &#8216;ups-agent&#8217;. You may edit that line to your VM&#8217;s name<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/sh\r\n\r\n# This script shuts down the UPS-Agent and resets the license\r\necho 'Getting VMID of UPS-Agent'\r\nvmid=$(vim-cmd vmsvc\/getallvms | grep ups-agent | awk '{print $1}')\r\necho 'VMID is' $vmid\r\n\r\necho 'Getting UPS-Agent Power state'\r\nstate=$(vim-cmd vmsvc\/power.getstate $vmid | grep Powered)\r\necho 'VM is currently' $state\r\nx=1\r\n\r\nwhile &#91;&#91; \"$state\" == \"Powered on\" &amp;&amp; $x -lt 3 ]]\r\ndo\r\n        echo 'Powering off...'\r\n        vim-cmd vmsvc\/power.shutdown \"$vmid\"\r\n        echo 'Waiting for VM to power off...'\r\n        i=30;while &#91; $i -gt 0 ];do if &#91; $i -gt 9 ];then printf \"bb$i\";else  printf \"bb $i\";fi;sleep 1;i=`expr $i - 1`;done\r\n        state=$(vim-cmd vmsvc\/power.getstate $vmid | grep Powered)\r\n        x=`expr $x + 1`\r\ndone\r\n\r\nif &#91; \"$state\" == \"Powered off\" ]\r\n        then\r\n        ## remove license\r\n        echo 'Removing License'\r\n        rm -r \/etc\/vmware\/license.cfg\r\n        ## get a new trial license\r\n        echo 'Copying new license'\r\n        cp \/etc\/vmware\/.#license.cfg \/etc\/vmware\/license.cfg\r\n        ## restart services\r\n        echo 'Restarting VPXA'\r\n        \/etc\/init.d\/vpxa restart\r\n        #echo 'Restarting Services'\r\n        #services.sh restart\r\n        ## power on\r\n        echo 'Powering on USP-Agent'\r\n        vim-cmd vmsvc\/power.on \"$vmid\"\r\nelse\r\n        echo 'Could not turn off UPS-Agent'\r\nfi\r\n\r\necho 'Finished'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Test the script and make sure it works (remember to chmod +x)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ chmod +x reset-eval.sh<br>.\/reset-eval.sh<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">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 * *<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/bin\/echo \"5 6 * * * \/vmfs\/volumes\/ZFS0\/reset-eval.sh\" >> \/var\/spool\/cron\/crontabs\/root<br>kill $(cat \/var\/run\/crond.pid)<br>crond<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Finally add the following to the end of &#8216;\/etc\/rc.local.d\/local.sh&#8217; to regenerate the job as ESXi clears the crontab on reboot<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/bin\/kill $(cat \/var\/run\/crond.pid)<br>\/bin\/echo \"5 6 * * * \/vmfs\/volumes\/ZFS0\/reset-eval.sh\" &gt;&gt; \/var\/spool\/cron\/crontabs\/root<br>crond<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 Note: Running [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":80,"comment_status":"closed","ping_status":"open","sticky":false,"template":"single-with-sidebar","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[6,7,8,9,10,11],"class_list":["post-6","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visualization","tag-cron","tag-esxi","tag-evaluation","tag-license","tag-reset","tag-script"],"_links":{"self":[{"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6"}],"version-history":[{"count":2,"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":23,"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions\/23"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=\/wp\/v2\/media\/80"}],"wp:attachment":[{"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguyenhieu.name.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}