Sunday, December 15, 2019

PowerCLI script to get HBA firmware and driver version for all ESXi hosts

This is a follow-up post on one of my earlier post, How to check FC hba driver & firmware version on ESXi host.

We can use the following PS script to find and list HBA firmware and driver versions for all ESXi hosts in a given Cluster.

You may need to change the HBA provider as one of the following per the hardware attached.
For Emulex hba : lpfc
Brocade hba : bfa
Qlogic hba : qlnativefc or qla*

$HBAList = @()

# Start Loop to run command against all hosts in the Staging Cluster

foreach ($vmhost in ((get-cluster Cluster_Name)| get-vmhost))

{
# Pipe the Get-esxcli cmdlet into the $esxcli variable

$esxcli = $vmhost | get-esxcli

# I used this to gather the VMHost Name for the exported CSV file

$VMHostName = $vmhost.Name

# This is the ESXCLI command I ran to get the Driver Version out of the ESXCLI System Module Get DCUI Shell

$HBAList += $esxcli.system.module.get("lpfc") | Select-object @{N="VMHostName";E={$VMHostName}}, Module, Version
}

# Results are compiled and exported to a CSV file

$HBAList | export-csv -path E:\ben\vmware\HBA_info.csv -notypeinformation

Referance: VMTN

That's it... :)


2 comments:

  1. Hi,

    I found this script on one of the online forums, but first you have to have PowerCli 6.5 or later.

    1- Start PowerCli.

    2- Connect to your vCenter using Connect-VIServer command.

    3- Copy the below script to a notepad file and then rename it to .ps1

    4- From the PowerCli shell, go to the destination of your ps1 script and then execute.



    This script has exported HBA and VNICs firmware and driver versions info for all of my HPE ESXI hosts.

    If you want specific cluster or specific host, change the first line of the script with one of the following;

    Example:
    $vmhosts = Get-VMHost fqdn-of-your-esxihost - Check a single Host
    $vmhosts = Get-Cluster you-cluster-name | Get-VMHost - Checks all hosts in a cluster
    $vmhosts = Get-VMHost - Checks all hosts in the vCenter





    Script is below:



    ################################################

    $vmhosts = Get-VMHost



    $report = @()



    foreach ($ESXHost in $vmhosts) {



    $esxcli = Get-EsxCli -vmhost $ESXHost



    $nicfirmware = $esxcli.network.nic.list()



    $fcfirmware = $esxcli.storage.san.fc.list()



    $driversoft = $esxcli.software.vib.list()



    foreach($nicfirmwareselect in $nicfirmware)



    {



    $NetworDescription = $nicfirmwareselect.Description



    $NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }



    $NetworkName = $nicfirmwareselect.Name



    $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)).DriverInfo.FirmwareVersion







    $report += "" |



    select @{N = "Hostname"; E = { $ESXHost.Name } },



    @{N = "Hardware-Model"; E = { $ESXHost.Model } },



    @{N = "device"; E = { $NetworkName } },



    @{N = "driver"; E = { $NetworDriver.Version } },



    @{N = "firmware"; E = { $NetworkFirmware } },



    @{N = "description"; E = { $NetworDescription } }



    }



    foreach($fcfirmwareselect in $fcfirmware)



    {



    $fcDescription = $fcfirmwareselect.ModelDescription



    $fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }



    $fcName = $fcfirmwareselect.Adapter



    $fcFirmware = $fcfirmwareselect.FirmwareVersion







    $report += "" |



    select @{N = "Hostname"; E = { $ESXHost.Name } },



    @{N = "Hardware-Model"; E = { $ESXHost.Model } },



    @{N = "device"; E = { $fcName } },



    @{N = "driver"; E = { $fcDriver.Version } },



    @{N = "firmware"; E = { $fcFirmware } },



    @{N = "description"; E = { $fcDescription } }



    }



    }



    $report | Export-Csv -Path 'C:\ESXI HBA & NIC info.csv'

    ########################################################################

    ReplyDelete