Hi everyone
I've been experimenting with shutting down my VMs and ESXi remotely.
After some googling and experimenting, I have the following script:
------------------
#!/bin/sh
vim-cmd vmsvc/getallvms | cut -d' ' -f1 | tail -n +2 | xargs -r -n1 vim-cmd vmsvc/power.suspend
sleep 180
/sbin/shutdown.sh && /sbin/poweroff
----------------
I've tested this and it seems to be working.
One question I do have is is it safe to use `/sbin/shutdown.sh && /sbin/poweroff`. I'm not sure if the scripts are executed in parallel or not. I've tried this on a test host (the script was executed from a machine NOT on the host itself) and it appears to work, but I don't know if I want to risk trying it without getting some feedback. It could be something simple like another sleep command between shutdown and poweroff, but I don't know if this is necessary.
Also, can the script be executed from a virtual machine on the host it's shutting down? (via plink.exe or something similar)
Next week I'll be trying to run it from a virtual machine residing on a host to see if it works, and if it does, I'll slowly start to deploy it.
Thanks,
Dan