Please enable Javascript for better experience...
Powershell Script - Get HBA/NIC Driver Information for Multiple ESXi Hosts
By Pranay Jha | Jun 6, 2017 | In Tips | Total Views [ 11581 ]
(1 Like)

PowerCLI Script to get HBA/NIC Driver Information for Multiple ESXi Hosts and Pull Report in CSV File.

Part - 1

  • Get Driver Modules for HBA and NIC Hardware. To get this, execute below command for one of ESXi Host. Make sure you are connected with vCenter before executing.

$esxName = 'HostName'

$esxcli = Get-EsxCli -VMHost $esxName

foreach($dev in $esxcli.hardware.pci.list()){

    if($dev.ModuleName -ne 'None'){

        $esxcli.system.module.get($dev.ModuleName) |

        Select @{N='Device';E={$dev.DeviceName}},@{N='DeviceClass';E={$dev.DeviceClassName}},Module,Version



  • You will get below output from above commands. Here we have HBA Hardware is running on "lpfc" and NIC on "elxnet" Module.
  • Now make a note of it. These hardware modules need to change in Part-2 script in place of "fnic" and "enic"

Part - 2

  • Replace "fnic" and "enic" in below script which you got from Part-1.

$report = Get-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="HostName";E={$($_.VMHost | Get-VMHostNetwork).HostName}},




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


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


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



                @{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={$ | ? {$_.Name -match ".*$($hba.hbadriver).*"} | Select -First 1 -Expand Vendor}},

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



               # @{N="Enicvendor";E={$ | ? {$_.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={$ | where {$ -eq $_.vmnic1} | select -First 1 -ExpandProperty Description }}



$report | Export-Csv report.csv -NoTypeInformation -UseCulture

Credit for this script is to Luc D.

Enjoy -:) . Let me know in case any suggestion or inputs.

Thanks for visiting here. Share this article if you found it useful.
Like Facebook Page
Connect to twitter
Subscribe my Channel
Connect over Linkedin
Share this on Social Media

About the Author

Pranay Jha
Pranay Jha
Founder, Contributer

Public profile: user/profile/99900000

Follow me

facebook linkedin twitter G+ VMTN youtube

Thank you for visiting my profile. I am Pranay Jha, bring along a total of 11+ years of extensive experience with me in Information Technology sector for organizations from small business to large enterprises, wherein my current assignment I am associated with IBM as a Technical Solution Architect for Virtualization platform. I am vExpert x 3 (16/17/18), VCIX-DCV, VCAP5/6-DCD, VCAP5-DCA, VCP7-CMA, VCP5/6-DCV, VCA-DCV, VCA-Cloud, VSP, VCE-CIA, MCITP, MCSE, MCSA(Messaging). I am also an Independent blogger and founder of and I can be reached via email at or Direct Message via Contact Us form.

Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Facebook Likes