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!

13 comments:

  1. This was really useful and I extended to add in NIC driver & firmware version. This was slightly complicated as there are multiple instances. This is to check our DL580 G7 hosts which have quad port adaptors with known firmware issue - VMware KB 2012455. The extra code I inserted was:

    $nsiNXdev = $arrNumericSensorInfo | ? {$_.Name -like "nx_nic device*"}
    $nsiNXdrv = $arrNumericSensorInfo | ? {$_.Name -like "nx_nic driver*"}
    # assume all at same level and take first or set as n/a
    if ( $nsiNXdev.Count -gt 0 ) {
    $nsiNXdevice = $nsiNXdev[0].Name
    } else {
    $nsiNXdevice = "n/a"
    }
    if ( $nsiNXdrv.Count -gt 0 ) {
    $nsiNXdriver = $nsiNXdrv[0].Name
    } else {
    $nsiNXdriver = "n/a"
    }
    New-Object PSObject -Property @{
    VMHost = $_.Name
    "SystemBIOS" = $nsiBIOS.name
    "HPSmartArray" = $nsiArrayCtrlr.Name
    "iLOFirmware" = $nsiILO.Name
    "nx_nic device" = $nsiNXdevice
    "nx_nic driver" = $nsiNXdriver

    Peter Polkinghorne

    ReplyDelete
    Replies
    1. Thanks for sharing, Peter! We are working on a similar add-on where it gets all NIC driver- and firmware versions, too.

      Delete
  2. Hi, is this script working for the ESXi 4.1 and 5.1 ?

    because I cannot get the value of nx_nic driver and nx_nic device value.

    ReplyDelete
    Replies
    1. Hello, albertwt-

      I just verified that, yes, this works for vSphere 4.1 using PowerCLI 5.1. The "extra code" that Peter shared needs inserted in a couple of parts:
      0) the extra code up to (excluding) the New-Object line get inserted before line 15 in the original code above
      1) the New-Object section of Peter's code would be substituted in place of the New-Object block that is lines 15-20 in the original code above.

      Give that a shot

      Delete
    2. Hi Matt @mtboren,

      I've tried to combine the script above but somehow there is no result in the nx_nic device and nx_nic driver column ?

      Here's the code:

      $strHostsClusterName = "Production"
      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*"}
      $nsiNXdev = $arrNumericSensorInfo | ? {$_.Name -like "nx_nic device*"}
      $nsiNXdrv = $arrNumericSensorInfo | ? {$_.Name -like "nx_nic driver*"}

      if ( $nsiNXdev.Count -gt 0 ) {
      $nsiNXdevice = $nsiNXdev[0].Name
      } else {
      $nsiNXdevice = "n/a"
      }
      if ( $nsiNXdrv.Count -gt 0 ) {z
      $nsiNXdriver = $nsiNXdrv[0].Name
      } else {
      $nsiNXdriver = "n/a"
      }

      New-Object PSObject -Property @{
      VMHost = $_.Name
      "SystemBIOS" = $nsiBIOS.name
      "HPSmartArray" = $nsiArrayCtrlr.Name
      "iLOFirmware" = $nsiILO.Name
      "nx_nic device" = $nsiNXdevice
      "nx_nic driver" = $nsiNXdriver
      } ## end new-object
      } | Export-Csv C:\temp\HPBL07.csv

      Delete
  3. I love this script, just what (well part of what...) the doctor ordered. I'm just trying to figure out how to get info the nic's we have. I know I need to edit the "$_.name -like" line but not sure what to change it to. I plan on taking this "current" information about firmware levels and bang it up against a list of currently available versions from HP. Does anyone know if HP has that info in a format that I can pull it into my script when I need it? Thanks again, this is awesome!

    ReplyDelete
  4. Hi Matt, It is not showing the iLO firmware version. iLO firmware version is "1.30" and in the script output's it is showing "Hewlett-Packard BMC Firmware (node 0) 46:10000.."

    Please help

    ReplyDelete
    Replies
    1. Hello, Anonymous-

      That "Hewlett-Packard BMC Firmware (node 0) 46:10000.." string is the value of the numeric sensor for iLO on that given host. If you check the full value of that string, you should see that it is something like:
          Hewlett-Packard BMC Firmware (node 0) 46:10000 1.30

      So, the firmware version string that we generally know and use should be in there, you just may need to manipulate the full string a bit if you want exactly "1.30" as the value. You could do so in a variety of ways, from a basic .Split() on the string to a bit more involved regular expression match. For example:

          PS C:\> "Hewlett-Packard BMC Firmware (node 0) 46:10000 1.30".Split(" ")[-1]
          1.30

      or, to use a regular expression:

          PS C:\> "Hewlett-Packard BMC Firmware (node 0) 46:10000 1.30" -match "Hewlett-Packard BMC Firmware \(node 0\) 46:10000 (?<verString>\d\.\d+$)"
          True
         
          PS C:\> $Matches["verString"]
          1.30

      How do those do?

      Edit: had to repost reply, as HTML was changing some of the regular expression pattern

      Delete
  5. That's amazing; I just changed "VMware Power Shell" properties and found that information was there . It's really helped me a lot.

    Is there any way, where we can get similar kind of information for IBM servers. In IBM there is no "iLO", it is called as "Integrated Management Module". By ESXi command line, we can find that information through "SMbiosDump | grep -i Integrated"
    *******************************************************************
    smbiosDump | grep Integrated
    $SI Integrated Management Module 1.41 -[YUOOF7C-1.41]-

    ReplyDelete
  6. I saw above where someone added NIC driver and firmware to this, and I have that working fine. But using the same methodology, I have not found a good way to determine the HBA firmware version. I have no problem getting the HBA driver version, even without the HP mechanisms, but so far the HBA firmware is a mystery directly using PowerCLI. I think it is possible by using plink and doing SSH through PowerShell, but I would like to do straight PowerCLI if possible.

    Anyone have any thoughts?

    ReplyDelete
  7. I cannot get the VMHost name to appear.

    ReplyDelete
  8. I am not getting details like ILO Firmware and smart aray details, do i need to install something extra.

    I get details like blow.
    iLOFirmware HPSmartArray SystemBIOS VMHost
    test.tst.lab.com

    ReplyDelete
    Replies
    1. Hello, @Rach-

      Yes, those additional details are made available to ESXi (and, so, to our code here) via the HPE VIBs being installed on the given target ESXi host. Use whatever way you like to install those (offline bundle from HP, for example), and you should then get the corresponding info that is surfaced by those VIBs.

      Enjoy,

      Matt

      Delete

Note: Only a member of this blog may post a comment.