Hey Guys ,
i've needed to write a script to shut down all virtual machines and an ESXi Host in a clean way using an UPS , so i've done some research , combined and upgraded several codes that i found in the internet , and came up with this little one ,
the script shuts downs the online VMs then puts the host in the maintenance mode , shuts down the host and disable the maintenance mode, the last step allows the host to restart normally .
i hope this helps