Everyday Virtualization

Blog archive

How To Determine ESXi Host Major Version, Install Date with PowerCLI

I will admit first of all that I am no scripter. But I find that when I go about the task of doing repetitive tasks, PowerCLI (vSphere's PowerShell extension) is the way to go. I usually also gravitate to Alan Renouf's site for a great selection of starter scripts, so cheers to you Alan!

In preparation for an upgrade to vSphere 5 for one environment, I needed to determine where each host was at. Sure, we can look in the vSphere cient and get the build number and something like ESXi 4.1. But without knowing the build numbers by memory, it may not be enough to tell us the entire story.

So, I whipped up the simplest one-liner PowerCLI script to tell me what release an ESX or ESXi host is at, as well as its install date. This is helpful to reconcile what we are expecting for the state of a host, as well as the supported configuration and options available for the host for the upgrade. Here's the script:

Get-VMHostPatch * | Select ID, InstallDate, VMHostID
Get-VMHost | Select ID, name

The script is simple and dirty and returns the selected information in two views. The VMHostPatch cmdlet returns only the real information I want coupled with a VMHostID. That is correlated in the Get-VMHost cmdlet, which returns the DNS name of the hosts in question. What is also cool about this is that it can report against multiple vCenter connections simultaneously (as can most cmdlets, for that matter).

The first step is to run the Connect-VIServer Cmdlet to enable the connection to the vCenter Server. Fig. 1 shows the report, which gives a quick and easy view to see what hosts are at what major version (such as Update 1, Update 2, etc.) before implementing the vSphere 5 upgrade for these environments.

This report shows the major versions as well as the host names for all hosts on the connected vCenter systems.

Figure 1. This report shows the major versions as well as the host names for all hosts on the connected vCenter systems. (Click image to view larger version.)

Have you written any PowerCLI scripts that you've used as part of your vSphere 5 upgrade procedures? If so, share your scripts or links to any relevant blog posts here.

Posted by Rick Vanover on 03/28/2012 at 12:48 PM


Featured

Subscribe on YouTube