Recently I was asked by someone how they could do rolling automated updates from ESXi 5.1 to ESX 5.1 Update 1 in their environment using PowerCLI, obviously there are a number of ways to achieve this and William Lam did a great job of showing these in this blog including a piece of sample PowerCLI code.

I figured I would share the code I used to perform this so that others may gain from this experience…

List the Hosts and their versions

Put the host into maintenance mode so we can install the patch

Download the patch from the VMware website and if the patch hasn’t been uploaded to a datastore already (remember if you want to use this for multiple hosts you will need to upload it to a shared datastore) you can do it like this:

(note for some strange reason I changed the variable from $vmhost to $vmh so please just replace where seen)

Install the patch on the host and reboot

The last parts of this script can obviously be put inside a foreach loop to update each host in the cluster, you would want to make certain that vMotion is happy and working in your environment before doing such an automated update though

And of course make sure you delete the update file when you are finished so that we are good admins and not using datastore space….

-Alan

Share this: Email

Print

Twitter

Facebook

Reddit

