Press "Enter" to skip to content

ESXi CLI Network and HBA Script

##################################################################################
#
#	Script:		hba&nicFw_Driver_Version_list.ps1
#	Author:		Fabio Irigoyen
#	Date:		17.02.2023
#	Desc:		Script to create a csv list with all drivers and
#                       firmwares of NIC adapters and HBA Adapters
#	Version:	1.0
#	History:	
#							
#
##################################################################################


#-------------------------------------------------------------------------------------------
# Variables
#-------------------------------------------------------------------------------------------


#-------------------------------------------------------------------------------------------
# Main
#-------------------------------------------------------------------------------------------

$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 'E:\temp\hba.csv'

Was this page helpful?