11 November 2011

Get HP Firmware Info for HP VMware Hosts Using PowerShell

In trying to keep our HP hosts current on firmware, we had the need to find what the hosts' current firmware levels were. So, we whipped up a quick spot of code to retrieve such info.  It relies on only Get-View to get the data, and we were sure to specify only the properties we needed, so you know it will be FAF:
## Script function: quickly get BIOS date, Smart Array FW version, and iLO FW version for HP hosts in a given location (folder, cluster, datacenter, etc.)
## Author: vNugglets.com -- Sep 2011

## folder in which hosts in which we are interested reside
#$strHostsFolderName = "myFolder"
#Get-View -ViewType HostSystem -Property Name, Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo -SearchRoot (Get-View -ViewType Folder -Property Name -Filter @{"Name" = "^$([RegEx]::escape($strHostsFolderName))$"}).MoRef | %{
## cluster in which hosts in which we are interested reside
$strHostsClusterName = "myCluster"
Get-View -ViewType HostSystem -Property Name, Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo -SearchRoot (Get-View -ViewType ClusterComputeResource -Property Name -Filter @{"Name" = "^$([RegEx]::escape($strHostsClusterName))$"}).MoRef | %{
    $arrNumericSensorInfo = @($_.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo)
    # HostNumericSensorInfo for BIOS, iLO, array controller
    $nsiBIOS = $arrNumericSensorInfo | ? {$_.Name -like "*System BIOS*"}
    $nsiArrayCtrlr = $arrNumericSensorInfo | ? {$_.Name -like "HP Smart Array Controller*"}
    $nsiILO = $arrNumericSensorInfo | ? {$_.Name -like "Hewlett-Packard BMC Firmware*"}
    New-Object PSObject -Property @{
        VMHost = $_.Name
        "SystemBIOS" = $nsiBIOS.name
        "HPSmartArray" = $nsiArrayCtrlr.Name
        "iLOFirmware" = $nsiILO.Name
    } ## end new-object
} ## end Foreach-Object

Lines 5-6 can be used instead of 8-9, in the case that one wants to get info on hosts in a particular inventory folder, instead of in a particular cluster.  Or, one can remove the -SearchRoot portion altogether, to get firmware info for all hosts in the given vCenter.

Note:  This technique relies on the HP CIM provider being installed and running properly on the VMware hosts.

An example of running the script and selecting a couple of the properties (for the sake of display width here) would look something like:
PS C:\> \\path\to\getHPHostFirmwareScript.ps1 | ft -a VMHost,SystemBIOS,HPSmartArray

VMHost            SystemBIOS                                  HPSmartArray
------            ----------                                  ------------
host0.domain.com  HP System BIOS P61 2009-07-10 00:00:00.000  HP Smart Array Controller HPSA1 Firmware 6.86
host1.domain.com  HP System BIOS P61 2009-07-10 00:00:00.000  HP Smart Array Controller HPSA1 Firmware 6.86
host2.domain.com  HP System BIOS P61 2010-10-25 00:00:00.000  HP Smart Array Controller HPSA1 Firmware 7.22
...

And, as for the speed:  for 175 hosts (some of which are in WAN-connected datacenters), this took about 16 seconds.  Not bad, not bad!