GabCava
Enthusiast
Enthusiast

Get HBA firmware and driver version for all ESXi hosts

Jump to solution

Hello, as you probably know the only way to find out about HBA firmware and driver versions these days is by running:

/usr/lib/vmware/vmkmgmt_keyval/vmkmgmt_keyval -d     to see which are the HBA devices, then

/usr/lib/vmware/vmkmgmt_keyval/vmkmgmt_keyval -l -i vmhba1/qlogic     to actually retrieve the needed  info for a hba. In this particular case I get this precious data below:

value:

QLogic PCI to Fibre Channel Host Adapter for QMH2562:

        FC Firmware version 8.02.00 (90d5), Driver version 2.1.50.0

which I need to retrieve from all my ESXi and save to a file. I enjoy writing simple powercli scripts but I'm puzzled about this one. I know that esxcli commands can be scripted too but what about this? I could script something with plink

$plink = plink path

$plinkAuth = " -v -pw $Pswd"

$remoteCommand = '/usr/lib/vmware/vmkmgmt_keyval/vmkmgmt_keyval -l -i vmhba1/qlogic'

$command = "Echo Yes| "+$plink + " " + $plinkAuth + " " + $User + "@" + $hostName + " " + $remoteCommand

$result = Invoke-Expression -command $command

$result

but as the command above throws quite some stuff I don´t know how to grab only the data output I need and save it. Obviously this is to compare with vmware compatibility matrix later. Anyone did this? I already checked Re: Host Hardware info with HBA and nic driver information but the following values are returned blank, and not sure those match the  ones above that I need. I already added  the -V2 switch to the script of that post.

Fnicvendor   :

fnicdriver   :

enicdriver   :

Enicvendor   :

28 Replies
LucD
Leadership
Leadership

Try changing the start of the script to

$vmhosts1 = Get-Content -Path "C:\Temp\HostList1.txt"


$report = @()

foreach ($ESXHost in (Get-VMHost -Name $vmhosts1)) {


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
swamynaveen
Enthusiast
Enthusiast

@LucD My Apologies for the delay. I had fever due to which couldn't login last few days. I've changed the script as per your suggestion. However, there is no luck and still getting same error. Kindly advise.

 

======script Start================

$vmhosts1 = Get-Content -Path "C:\Temp\HostList1.txt"

$report = @()

foreach ($ESXHost in (Get-VMHost -Name $vmhosts1)) {

 

$esxcli = Get-EsxCli -VMHost $ESXHost -V2

 

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

 

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

 

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

 

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:\Temp\ESXI HBA & NIC info.csv" -NoClobber -NoTypeInformation

========Script End============

 

Error details:

===========

Object of type 'InternalVimApi_50.ManagedObjectReference' cannot be converted to type 'System.String'.
At line:22 char:1
+ $fcfirmware = $esxcli.storage.san.fc.list.Invoke()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException

Object of type 'InternalVimApi_50.ManagedObjectReference' cannot be converted to type 'System.String'.
At line:26 char:1
+ $driversoft = $esxcli.software.vib.list.Invoke()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'get'.
At line:50 char:1
+ $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (get:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'get'.
At line:50 char:1
+ $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (get:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'get'.
At line:50 char:1
+ $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (get:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'get'.
At line:50 char:1
+ $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (get:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'get'.
At line:50 char:1
+ $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (get:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

 

Regards,

Naveen

0 Kudos
LucD
Leadership
Leadership

Works for me.
What do you have in that .TXT file?
The name of 1 ESXi node per line, no column headers?

Btw, the line $esxcli.network.nic.get($nicfirmwareselect.Name) is wrong when using the V2 switch on Get-EsxCli.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
swamynaveen
Enthusiast
Enthusiast

@LucD Please find required details below.

 

What do you have in that .TXT file? List of host names with FQDN
The name of 1 ESXi node per line, no column headers? Yep.

 

 

Regards,

Naveen

0 Kudos
LucD
Leadership
Leadership

Not a lot I can further deduce from that error.
I would suggest you add some Write-Host lines to see what is each variable.
Starting with the $esxHost and $esxcli variable


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
swamynaveen
Enthusiast
Enthusiast

@LucD Here are variables output. also, I'm getting permission denied message. What all the permissions needed to use below cmdlet and to call below methods.

Get-EsxCli

$esxcli.network.nic.list.Invoke()

$esxcli.storage.san.fc.list.Invoke()

$esxcli.software.vib.list.Invoke()

 

swamynaveen_0-1618378954797.png

Regards,

Naveen

0 Kudos
LucD
Leadership
Leadership

Like I said earlier, there is not a lot I can do remotely.
It looks odd that you now all of a sudden have a permission error.
You will have to debug this yourself, since it seems to be something specific to your environment.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
swamynaveen
Enthusiast
Enthusiast

@LucD finally I was able to fetch the HBA firmware/Driver version details after connecting to vsphere.local super user. I just want to know which permissions are required to be able to execute below methods using ADS user. Kindly advise.

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

 

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

 

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

HostnameHardware-Modeldevicedriver VersiondriverFirmware Versiondescription
HostName1ProLiant BL460c Gen9vmhba012.0.1211.0-1OEM.670.0.0.8169922brcmfcoe11.4.1231.6HP FlexFabric 20Gb 2-port 650FLB Adapter
HostName1ProLiant BL460c Gen9vmhba112.0.1211.0-1OEM.670.0.0.8169922brcmfcoe11.4.1231.6HP FlexFabric 20Gb 2-port 650FLB Adapter
HostName3ProLiant BL460c Gen9vmhba012.0.1211.0-1OEM.670.0.0.8169922brcmfcoe11.4.1231.6HP FlexFabric 20Gb 2-port 650FLB Adapter
HostName3ProLiant BL460c Gen9vmhba112.0.1211.0-1OEM.670.0.0.8169922brcmfcoe11.4.1231.6HP FlexFabric 20Gb 2-port 650FLB Adapter
HostName2ProLiant BL460c Gen9vmhba012.0.1211.0-1OEM.670.0.0.8169922brcmfcoe11.4.1231.6HP FlexFabric 20Gb 2-port 650FLB Adapter
HostName2ProLiant BL460c Gen9vmhba112.0.1211.0-1OEM.670.0.0.8169922brcmfcoe11.4.1231.6HP FlexFabric 20Gb 2-port 650FLB Adapter

Regards,

Naveen

0 Kudos
LucD
Leadership
Leadership

No clue


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos