Updating from ESXi 5.1 to ESXi 5.1 Update1 with PowerCLI

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

clip_image002

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

clip_image004

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)

clip_image006

Install the patch on the host and reboot

clip_image008

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 Winking smile

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….

image

Leave a Reply