Automate VM startup and/or force shutdown

Hello!
In my homelab I have a VMware ESXi 6.5 Server.
One of the VM’s is a WDS server with MDT.
I have separate VM’s for each Windows version. The VM’s are also setup with non persistent disks.
Due to resource limitations, I can’t efficiently run more then one at a time (limitations when the homelab consists of OLD computers…).
And it gets quite tedious to start them manually one by one (can take 2-3 hours per image…). Or shut them down if one hangs…

My current need is to find a way to start one VM after the previous one has powered off.
Second it should force shutdown the VM if power on time equals X amount of hours.

I was reccomended to make a PowerShell script with PowerCLI commands.

But I have no experience with PowerShell or PowerCLI (or any other coding).
Could not find any guides online that fits my need.
So I was wondering if someone could point me in the right direction?

Thanks
-Yngve

1 Like

Not sure on your specific ‘licensing’ setup for your ESXi server, but you should be able to use ‘esxcli’ to control your virtual machines from the ESXi hypervisor level.

You’ll need to enable some settings such as SSH and ESXi Shell.

Here is an article that should be helpful for you :slight_smile:

Thanks for the reply @anon27052951 :grin:

I forgot to add that I have vCenter installed on the server.
Thats how I was thinking of running the script (If posible).

I’ll second PowerCLI. For your use case, SSHing into your vCenter server and running whatever scripts/commands you need to will be faster once setup than going to the GUI every time