I have a home ESXi server that is on 24/7. This wasn't previously a problem, but with UK electricity costs scheduled to increase to 52p per kW/h, I'd like to set up a schedule to automatically power down the server when not in use.
It is a Dell T3610 workstation and has the option for 'power recovery' or 'scheduled power on'. That gives me the choice of using a smart plug to power it on or I can simply set a schedule in the BIOS.
Shutting down the machine is more complex. ESXi doesn't include a power-off scheduling feature.
Is it possible, maybe via a package, to have OpenWrt SSH to the ESXi server, authenticate and then issue the shutdown command?
The only VM that I'm currently running is Windows Server 2019 and I only need it to be powered on between 6pm and midnight. I can use Task Scheduler to shut down the Windows VM each evening and then power down the ESXi host ten minutes later.
This also looks promising, but vsphere CLI has been deprecated. I have installed the new solution esxicli, but I don't have a clue how to use it or create the scheduled task.
The best way to accomplish this is via vSphere CLI, you need a Windows or Linux machine for this or you can also use the vSphere Management Appliance (free product)
1. create a cronjob or a scheduled task on the Windows/Linux client with this command
"vicfg-hostops.pl" -a poweroff -f --server=***ESXIHOSTNAME/IP*** --username ***root*** --password ***YOUR PASSWORD***--operation shutdown"