First of all, thank you for your help and I'm sorry for the time I took to reply.
In fact I had already seen that article.
But the difference in my scenario is that, as I stated at the beginning of my question, I want to shutdown the VMs accoding to the current system autostart policy ( I'm sorry I wrote "shutdown policy" in the first line.
Meanwhile I found this article: https://daviddever.net/gracefully-stopping-esxi-host-with-usb-ups/ and this one: https://administrator.de/forum/funktioniert-script-esx-msa-shutdown-stromausfall-385489.html (this one is in german but I used Google translator) and this: http://www.designervisuals.com/Shutdown_ESXi_and_VMs_During_a_Power_Failure.html
They are mostly related to shutdown ESXi on UPS power failure, but the result is the same I want to accomplish.
So I'll presume that it will in fact shutdown all machines correctly and will use it in my script
Thank you very much.