A new ESXi 6.5 patch came out today:

https://kb.vmware.com/s/article/2151104

And I wanted to upgrade my whole lab environment to it and I haven’t set up auto-deploy or update manager yet (I plan to, making all of this much easier to manage). So I wrote a quick and dirty PowerCLI script that updates to the latest patch and if the host doesn’t have any VMs on it, puts it into maintenance mode and reboots it. I will reboot the other ones as needed.

So short, not really even worth throwing on GitHub, but I might make it cleaner, and smarter at some point and put it there.

By the way, if you aren’t using Visual Studio Code for your PowerShell yet, I highly recommend it. Great for that and other languages–I have been working on some vRO stuff, and it has been helpful in authoring the JavaScript.

Some notes on this script:

  • Use are your own danger! It does reboot hosts, though only ones with no VMs. There is no error checking etc., etc.
  • I am using the standard build, so if you have special build this won’t be the exact process.

Enjoy.