Enthusiast
Enthusiast

PowerCLI Script to get ESXi Network/Storage Firmware and Driver Version

Jump to solution

Hi Admin,

Found this script which gets me firmware and driver info.

-------

$vmhosts = Get-Cluster "clust01" | get-vmHost

$report = @()

foreach( $ESXHost in $vmhosts) {

$HWModel = get-vmHost $ESXHost | Select Name, Model

$esxcli = Get-ESXcli -vmhost $ESXHost

if($HWModel.Model -eq "ProLiant BL460c Gen9")

{

$info = $esxcli.network.nic.get("vmnic0").DriverInfo | select Driver, FirmwareVersion, Version

$ModuleName = "$($info.Driver)"

$Firmware = "$($info.FirmwareVersion)"

$Driver = "$($info.Version)"

$elxnet = $esxcli.software.vib.list() | where { $_.name -eq "elxnet"}

$report += $info | select @{N="Hostname"; E={$ESXHost}},@{N="Hardware-Model"; E={$HWModel.Model}},@{N="Adapter-Firmware"; E={$Firmware}}, @{N="Network-Driver"; E={$Driver}}, @{N="FC-Driver"; E={$elxnet.version.substring(0,14)}}

}

}

$report | out-gridview

-------

Above works fine for my blade servers with CNAs.

But on some om my VMhost I have separate FC HBAs , and to get the driver info I use something like this :
$esxcli.system.module.get("lpfc") | Select-object @{N="VMHostName";E={$VMHostName}}, Module, Version

Possible to combine this line with my script someway?  

Thanks

Johan

1 Solution

Accepted Solutions
Leadership
Leadership

Try like this

$vmhosts = Get-Cluster "clust01" | Get-VMHost

$report = @()

foreach( $ESXHost in $vmhosts) {

    $HWModel = Get-VMHost $ESXHost

    $esxcli = Get-EsxCli -vmhost $ESXHost

    if($HWModel.Model -eq "ProLiant BL460c Gen9")

    {

        $info = $esxcli.network.nic.get("vmnic0")

        $elxnet = $esxcli.software.vib.list() | where { $_.name -eq "elxnet"}

        $lpfc = $esxcli.system.module.list() | where{$_.Name -eq 'lpfc'}

        if($lpfc){

            $lpfc = $esxcli.system.module.get("lpfc")

        }

        $report += $info |

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

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

                @{N="Adapter-Firmware"; E={$_.DriverInfo.FirmwareVersion}},

                @{N="Network-Driver"; E={$_.DriverInfo.Version}},

                @{N="FC-Driver"; E={$elxnet.version.substring(0,14)}},

                @{N='HBA-Module';E={$lpfc.Module}},

                @{N='HBA-Version';E={$lpfc.Version}}

    }

}

$report | Out-GridView


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

View solution in original post

31 Replies
Leadership
Leadership

Do you have ESXi nodes with both cards (Light Pulse & OneConnect)?

And how do want to see that in the resulting output? Which columns with which content?


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

0 Kudos
Enthusiast
Enthusiast

Hi Luc!

Yes, Some of my blade servers have 2 cards

FLB 650  for Networking

LPe1605 FC HBAs for storage

The script I have today works fine for my servers which only have the 650 FLB adapter

pastedImage_2.png

The goal is to retrieve the same info from ESXi nodes which also have the LP card. (Adapter-Firmware and FC-Driver)

Regards

Johan

Leadership
Leadership

Can you try like this?

$vmhosts = Get-Cluster "clust01" | Get-VMHost

$report = @()

foreach( $ESXHost in $vmhosts) {

    $HWModel = Get-VMHost $ESXHost

    $esxcli = Get-EsxCli -vmhost $ESXHost

    if($HWModel.Model -eq "ProLiant BL460c Gen9")

    {

        $info = $esxcli.network.nic.get("vmnic0")

        $elxnet = $esxcli.software.vib.list() | where { $_.name -eq "elxnet"}

        $lpfc = $esxcli.system.module.list() | where{$_.Name -eq 'lpfc'}

        $report += $info |

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

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

                @{N="Adapter-Firmware"; E={$_.DriverInfo.FirmwareVersion}},

                @{N="Network-Driver"; E={$_.DriverInfo.Version}},

                @{N="FC-Driver"; E={$elxnet.version.substring(0,14)}},

                @{N='HBA-Module';E={$lpfc.Module}},

                @{N='HBA-Version';E={$lpfc.Version}}

    }

}

$report | Out-GridView


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

Enthusiast
Enthusiast

Thanks, but the output is empty Smiley Sad
pastedImage_0.png

pastedImage_0.png

//Johan

0 Kudos
Leadership
Leadership

That produces an error when there is no HBA present.

Can you check what this returns on an ESXi nodes with a HBA?

$esxcli.system.module.list() | where{$_.Name -eq 'lpfc'}


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

0 Kudos
Enthusiast
Enthusiast

pastedImage_0.png

0 Kudos
Leadership
Leadership

Try like this

$vmhosts = Get-Cluster "clust01" | Get-VMHost

$report = @()

foreach( $ESXHost in $vmhosts) {

    $HWModel = Get-VMHost $ESXHost

    $esxcli = Get-EsxCli -vmhost $ESXHost

    if($HWModel.Model -eq "ProLiant BL460c Gen9")

    {

        $info = $esxcli.network.nic.get("vmnic0")

        $elxnet = $esxcli.software.vib.list() | where { $_.name -eq "elxnet"}

        $lpfc = $esxcli.system.module.list() | where{$_.Name -eq 'lpfc'}

        if($lpfc){

            $lpfc = $esxcli.system.module.get("lpfc")

        }

        $report += $info |

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

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

                @{N="Adapter-Firmware"; E={$_.DriverInfo.FirmwareVersion}},

                @{N="Network-Driver"; E={$_.DriverInfo.Version}},

                @{N="FC-Driver"; E={$elxnet.version.substring(0,14)}},

                @{N='HBA-Module';E={$lpfc.Module}},

                @{N='HBA-Version';E={$lpfc.Version}}

    }

}

$report | Out-GridView


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

View solution in original post

Enthusiast
Enthusiast

pastedImage_0.png

Many thanks Luc!!!

Regards

Johan

0 Kudos
Contributor
Contributor

The code very usefull but it has some limitations.

Ca some one help me to pull out hba Firmware version in entire Vcentre. the code work at cluster level.

Also it should work regardless of model (if($HWModel.Model -eq "ProLiant BL460c Gen9"))

0 Kudos
Leadership
Leadership

As I already mentioned in your other thread (Get HBA and NIC firmware and Driver version details ), afaik it is only possible to to get the HBA firmware version with the /usr/lib/vmware/vmkmgmt_keyval/vmkmgmt_keyval -l -i command in a SSH session to the ESXi node.

In this case the specific HW allowed another option, but that does NOT work for all vendors and all HBA types!


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

0 Kudos
Contributor
Contributor
Thnaks for your response LucD. the above code\script is working in my environment. as our infra Hardware is HP only.
0 Kudos
Leadership
Leadership

I understand, but the above code is not giving the HBA firmware version, only the HBA module version.


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

0 Kudos
Virtuoso
Virtuoso

Hi LucD​,

When I edit the script in these two lines:

$lpfc = $esxcli.system.module.list() | where{$_.Name -eq '*'}

and

$lpfc = $esxcli.system.module.get("*")

I cannot get any result on the HBA module and HBA version ?

/* Any kind of comment or input would be greatly appreciated */
0 Kudos
Leadership
Leadership

I'm afraid not, you will have to provide a name of a module.

You can list all the modules with

$esxcli.system.module.list()

If the vendor/type of HBA supports it, you can do the following to get the driver and version.
That way you don't have to hardcode the modulename.

foreach($hba in Get-VMHost | Get-VMHostHba -Type FibreChannel){

   $esxcli = Get-EsxCli -VMHost $hba.VMHost

   $esxcli.storage.san.fc.list() | where{$_.Adapter -eq $hba.Device} |

  Select @{N='VMHost';E={$hba.VMHost.Name}},

   @{N='HBA';E={$hba.Name}},

  ModelDescription,DriverName,DriverVersion,FirmwareVersion,HardwareVersion

}


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

0 Kudos
Contributor
Contributor

Hi, we have got around 200+ hosts, of which few have emulex nics and few broadcom. Would like to run a script to first check for module loaded for the specific nic and the driver version, for al the hosts.  The below line from the script, retreive the module name, need some help to pass the output of this command to esxcli software vib list (), to find the respective drivers.

$report = Get-Datacenter | % {   

      $datacenter=$_ 

      foreach($esx in Get-VMhost -Location $datacenter){ 

        $esxcli = Get-EsxCli -VMHost $esx 

        $nic = Get-VMHostNetworkAdapter -VMHost $esx | Select -First 1 | select -ExpandProperty Name 

        $hba =Get-VMHostHBA -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"} |  Select -First 1 |select -ExpandProperty Name 

       Get-VMHostHBA -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"} | 

        Select @{N="Datacenter";E={$datacenter.Name}}, 

                @{N="VMHost";E={$esx.Name}}, 

                @{N="HostName";E={$($_.VMHost | Get-VMHostNetwork).HostName}}, 

                @{N="version";E={$esx.version}}, 

                @{N="Manufacturer";E={$esx.Manufacturer}}, 

                @{N="Hostmodel";E={$esx.Model}}, 

                @{Name="SerialNumber";Expression={$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |Where-Object {$_.IdentifierType.Key -eq "Servicetag"} |Select-Object -ExpandProperty IdentifierValue}}, 

                @{N="Cluster";E={ 

                    if($esx.ExtensionData.Parent.Type -ne "ClusterComputeResource"){"Stand alone host"} 

                    else{ 

                        Get-view -Id $esx.ExtensionData.Parent | Select -ExpandProperty Name 

                   }}}, 

                Device,Model,Status, 

 

                @{N="WWPN";E={((("{0:X}"-f $_.NodeWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}}, 

               @{N="WWN";E={((("{0:X}"-f $_.PortWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}}, 

                @{N="Fnicvendor";E={$esxcli.hardware.pci.list() | where {$hba -contains $_.VMKernelName} |Select -ExpandProperty VendorName }}, 

@{N="FnicModule";E={$esxcli.hardware.pci.list() | where {$hba -contains $_.VMKernelName} |Select -ExpandProperty ModuleName }}, 

                

         @{N="Enicvendor";E={$esxcli.hardware.pci.list() | where {$nic -contains $_.VMKernelName} |Select -ExpandProperty VendorName }} 

         @{N="enicModule";E={$esxcli.hardware.pci.list() | where {$nic -contains $_.VMKernelName} |Select -ExpandProperty ModuleName }},

                     } 

}

 

New to powercli, so please excuse my ignorance on the code/syntax

$report = Get-Datacenter | % {   
 
      $datacenter=$_ 
 
      foreach($esx in Get-VMhost -Location $datacenter){ 
 
        $esxcli = Get-EsxCli -VMHost $esx 
 
        $nic = Get-VMHostNetworkAdapter -VMHost $esx | Select -First 1 | select -ExpandProperty Name 
 
        $hba =Get-VMHostHBA -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"} |  Select -First 1 |select -ExpandProperty Name 
 
        Get-VMHostHBA -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"} | 
 
        Select @{N="Datacenter";E={$datacenter.Name}}, 
 
                @{N="VMHost";E={$esx.Name}}, 
 
                @{N="HostName";E={$($_.VMHost | Get-VMHostNetwork).HostName}}, 
 
                @{N="version";E={$esx.version}}, 
 
                @{N="Manufacturer";E={$esx.Manufacturer}}, 
 
                @{N="Hostmodel";E={$esx.Model}}, 
 
                @{Name="SerialNumber";Expression={$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |Where-Object {$_.IdentifierType.Key -eq "Servicetag"} |Select-Object -ExpandProperty IdentifierValue}}, 
 
                @{N="Cluster";E={ 
 
                    if($esx.ExtensionData.Parent.Type -ne "ClusterComputeResource"){"Stand alone host"} 
 
                    else{ 
 
                        Get-view -Id $esx.ExtensionData.Parent | Select -ExpandProperty Name 
 
                    }}}, 
 
                Device,Model,Status, 
 
                @{N="WWPN";E={((("{0:X}"-f $_.NodeWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}}, 
 
                @{N="WWN";E={((("{0:X}"-f $_.PortWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}}, 
 
              # @{N="Fnicvendor";E={$esxcli.software.vib.list() | ? {$_.Name -match ".*$($hba.hbadriver).*"} | Select -First 1 -Expand Vendor}}, 
 
                @{N="Fnicvendor";E={$esxcli.hardware.pci.list() | where {$hba -contains $_.VMKernelName} |Select -ExpandProperty VendorName }}, 
 
                @{N="fnicdriver";E={$esxcli.system.module.get("").version}}, 
 
                @{N="enicdriver";E={$esxcli.system.module.get("").version}}, 
 
               # @{N="Enicvendor";E={$esxcli.software.vib.list() | ? {$_.Name -match ".net.*"} | Select -First 1 -Expand Vendor}} 
 
                 @{N="Enicvendor";E={$esxcli.hardware.pci.list() | where {$nic -contains $_.VMKernelName} |Select -ExpandProperty VendorName }} 
 
                 #@{N="Enicvendor";E={$esxcli.network.nic.list() | where {$vmnic.name -eq $_.vmnic1} | select -First 1 -ExpandProperty Description }} 
 
      } 
 
}
 
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
0 Kudos
Contributor
Contributor

Hi LuCD,

I dont see any output. Is it for just HP Proliant ? The script run and nothing happen not output.

It just finish after running for sometime. Am i missing something ? Is it i have to do or run in some other way ?

Thanks

Bikash

0 Kudos
Leadership
Leadership

I'm not sure which script in this thread you are running, but there are indeed some filters applied.

The 1st script actually checks for a Proliant.
The other are intended for FC HBAs.


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

0 Kudos
Contributor
Contributor

This script. When I am running this for my environment where Dell power edge servers are there it doesn't give anything. Even when I change the model from proliant to dell in the script.

How can we make it generic irrespective of server model.

$vmhosts = Get-Cluster "clust01" | Get-VMHost

$report = @()

foreach( $ESXHost in $vmhosts) {

    $HWModel = Get-VMHost $ESXHost

    $esxcli = Get-EsxCli -vmhost $ESXHost

    if($HWModel.Model -eq "ProLiant BL460c Gen9")

    {

        $info = $esxcli.network.nic.get("vmnic0")

        $elxnet = $esxcli.software.vib.list() | where { $_.name -eq "elxnet"}

        $lpfc = $esxcli.system.module.list() | where{$_.Name -eq 'lpfc'}

        if($lpfc){

            $lpfc = $esxcli.system.module.get("lpfc")

        }

        $report += $info |

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

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

                @{N="Adapter-Firmware"; E={$_.DriverInfo.FirmwareVersion}},

                @{N="Network-Driver"; E={$_.DriverInfo.Version}},

                @{N="FC-Driver"; E={$elxnet.version.substring(0,14)}},

                @{N='HBA-Module';E={$lpfc.Module}},

                @{N='HBA-Version';E={$lpfc.Version}}

    }

}

$report | Out-GridView

0 Kudos
Leadership
Leadership

You can just leave out the line where the Model is tested (and the braces - start & end).
But be aware that the DriverInfo information is dependent on the HW vendor.
Not all properties in there might have a meaningful value.

$vmhosts = Get-Cluster "clust01" | Get-VMHost


$report = @()


foreach ( $ESXHost in $vmhosts) {

  $esxcli = Get-EsxCli -vmhost $ESXHost

  $info = $esxcli.network.nic.get("vmnic0")

  $elxnet = $esxcli.software.vib.list() | where { $_.name -eq "elxnet" }

  $lpfc = $esxcli.system.module.list() | where { $_.Name -eq 'lpfc' }

  if ($lpfc) {

    $lpfc = $esxcli.system.module.get("lpfc")

  }

  $report += $info |

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

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

  @{N = "Adapter-Firmware"; E = { $_.DriverInfo.FirmwareVersion } },

  @{N = "Network-Driver"; E = { $_.DriverInfo.Version } },

  @{N = "FC-Driver"; E = { $elxnet.version.substring(0, 14) } },

  @{N = 'HBA-Module'; E = { $lpfc.Module } },

  @{N = 'HBA-Version'; E = { $lpfc.Version } }

}

$report | Out-GridView


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

0 Kudos