Automation

 View Only
  • 1.  PowerCLI Reset ESXi Eval licences

    Posted Jan 02, 2024 11:31 AM

    Hi All

    Looking for a way to reset the evaluation licences on my Lab Nested ESXi hosts [via a scripted method like PowerShell].

    I have the CLI commands to reset them which of course work fine.

    I've tried setting this up as an .SH script run as chron job but it seems with ESXi 7 the configuration required  to set a chron job as persistent across Host reboots has been removed. [Where UEFI boot is enabled] .

    Any ideas if there is another way to achieve the same end so it can be run say once a week etc..

    Kr

    P



  • 2.  RE: PowerCLI Reset ESXi Eval licences

    Posted Jan 02, 2024 12:20 PM

    If you have the Posh-Ssh module installed, you could try with

     



  • 3.  RE: PowerCLI Reset ESXi Eval licences

    Posted Jan 02, 2024 02:04 PM

    Hi Luc

    Was hacking around with something similar but haven't been able to get it to work yet.

    Thanks for the tip will carry on for the day then look ad the module you recommend

     

    P



  • 4.  RE: PowerCLI Reset ESXi Eval licences

    Posted Jan 02, 2024 03:29 PM
      |   view attached

    Hi Luc

    I gave up with mine in the end...

    Loaded in Posh-SSH and the script below looks good and it works (where the Eval Licence is extended)

    Except it generates an error cant (Communicate with Host) and leaves the SSH service still running.

     

    P



  • 5.  RE: PowerCLI Reset ESXi Eval licences

    Posted Jan 02, 2024 04:12 PM

    That might be because of the vcsa service restart.
    You might want to add a sleep before trying to stop the SSH service.
    Or wait in a loop till the ESXi node states "connected'



  • 6.  RE: PowerCLI Reset ESXi Eval licences

    Posted Jan 03, 2024 09:45 AM

    Hi Luc 

    Indeed a Sleep statement sorted it.

    Sorry should of thought of that myself I've seen similar things happen many times before when pause was required.

    .

    Almost perfect now I think however I think I need a "ForEach" in there some where to cover the 3 hosts in the cluster.

    Have tried manually entering the host names but it doesn't seem to want to play nice.

    Kr



  • 7.  RE: PowerCLI Reset ESXi Eval licences

    Posted Jan 03, 2024 10:23 AM

    Assuming that the credentials on each ESXi node in the cluster are the same, you could do something like this

    PS: add a Sleep if required



  • 8.  RE: PowerCLI Reset ESXi Eval licences

    Posted Jan 03, 2024 11:27 AM

    Looks like that could well be it !

    .

    Will rerun again tomorrow to check.

    Why are these scripts never as simple as they first seem 

    Thanks for all your help !



  • 9.  RE: PowerCLI Reset ESXi Eval licences

    Posted Jan 02, 2024 01:53 PM

    Connect-VIServer -Server <ESXi_hostname> -User <username> -Password <password>
    Get-VMHost | Get-VMHostLicense | Set-VMHostLicense -NewLicenseKey (Get-VMHostLicense | Select -ExpandProperty LicenseKey)

     

    you can automate the above script by using 

    either Windows Task Scheduler or VMware vCenter Orchestrator (vCO)

    to Schedule the workflow to run weekly