The problem with what I have, even though it seems to work pretty well when testing shutdown from the host UI, is that I need to manually keep the script up to date (in terms of VMs on my system) and I have about 20 VMs at the current time, but that can and does change and I expect having to keep the script up to date will become an annoyance over time.
It's possible to get a list of running vms using "vmrun list", which returns a list of paths to the .vmx files of running VMs.
Which is perfect for synthezising the appropriate shutdowns commands dynamically.
It would require some more advanced scripting than your current script... And I'm a linux user myself so I can't help you there.
Yes hibernation would make life simpler all round; I never considered that since I thought (incorrectly) that it may not play well with my system encryption, but I'm not sure where I got that idea from since it should be fine. I'm not sure if my UPS software will issue a hibernate command or just a balls out shutdown though. I'll have to see if it's only going to issue a shutdown command whether I can override that somehow. I also just read that the UPS I have will itself shut off 2 minutes after the shutdown command is executed, so if I have multiple VMs running 2 minutes might not be enough to suspend them all and shut down the way I have it configured now. Maybe hibernate is the best way to go if I can get it to work (i.e., get the UPS to initiate a hibernate either directly or indirectly); the only way I can see myself figuring this out is by simulating a power outage (unplugging the UPS).
Thanks for the info.
Actually it looks like my UPS software will hibernate, so I just need to capture that and issue the command to my other machine running on the same UPS. That will save all the VM shutdown hoops I am currently jumping through.