HOW TO: Find HBA WWN number on VMware vSphere ESX server

There are several ways to get HBA WWNs on VMware vSphere ESX/ESXi host:

  1. vSphere Client;
  2. Using ESXi Shell;
  3. Using Powershell / PowerCLI script.

1. Connect to a server or vCenter, open server Configuration tab, under Hardware select Storage Adapters:

You can also copy WWNN (World Wide Node Name) and WWPN (World Wide Port Name)

2. How to find HBA WWN via ESXi Shell / CLI:

VMware vSphere ESXi 5.0+:

~ # esxcli storage core adapter list
HBA Name  Driver        Link State  UID                                   Description
--------  ------------  ----------  ------------------------------------  ------------------------------------------------------------
vmhba0    megaraid_sas  link-n/a    unknown.vmhba0                        (0:1:0.0) LSI / Symbios Logic MegaRAID SAS SKINNY Controller
vmhba1    fnic          link-up     fc.20000025b5020110:20000025b502a121  (0:8:0.0) Cisco Systems Inc Cisco VIC FCoE HBA Driver
vmhba2    fnic          link-up     fc.20000025b5020110:20000025b502a120  (0:9:0.0) Cisco Systems Inc Cisco VIC FCoE HBA Driver

VMware ESX/ESXi 2.1.0 – 4.1.x:

~ # esxcfg-scsidevs -a
vmhba0  megaraid_sas      link-n/a  unknown.vmhba0                          (0:1:0.0) LSI / Symbios Logic MegaRAID SAS SKINNY Controller
vmhba1  fnic              link-up   fc.20000025b5020110:20000025b502a121    (0:8:0.0) Cisco Systems Inc Cisco VIC FCoE HBA Driver
vmhba2  fnic              link-up   fc.20000025b5020110:20000025b502a120    (0:9:0.0) Cisco Systems Inc Cisco VIC FCoE HBA Driver


  • Connect to ESXi shell either via putty/SSH or DCUI (Direct Console User Interface) / server console
  • Run ‘ls /proc/scsi/‘ and check the folder names:
    ~ # ls /proc/scsi/
     mptsas   qla2xxx
  • Look for a folder like ‘qla2xxx‘ – QLogic HBA, ‘lpfc820‘ – Emulex HBA, ‘bnx2i” – Brocade HBA;
  • Run ‘ls /proc/scsi/qla2xxx’. You will get a list of files, named by a number. Each file contains information about one HBA;
    ~ # ls /proc/scsi/qla2xxx/
    6  7
  • Now run ‘cat /proc/scsi/qla2xxx/6‘ to get full info on the HBA. Alternatively, run the following commands:
    • Run ” cat /proc/scsi/qla2xxx/6 | grep -A3 ‘SCSI Device Information:’  ” to get WWNN and WWPNs:
      ~ # cat /proc/scsi/qla2xxx/6 | grep -A3 'SCSI Device Information:'
      SCSI Device Information:
    • Run ” cat /proc/scsi/qla2xxx/6 | grep ‘Host Device Name’ ” to get vmhba number:
      ~ # cat /proc/scsi/qla2xxx/6 | grep 'Host Device Name'
      Host Device Name vmhba3

3. Powershell script to list host name, vmhba number, HBA model / driver and World Wide Port Name (WWN):
$scope = Get-VMHost     # All hosts connected in vCenter
#$scope = Get-Cluster -Name 'MyCluster' | Get-VMHost # All hosts in a specific cluster
foreach ($esx in $scope){
Write-Host "Host:", $esx
$hbas = Get-VMHostHba -VMHost $esx -Type FibreChannel
foreach ($hba in $hbas){
$wwpn = "{0:x}" -f $hba.PortWorldWideName
Write-Host `t $hba.Device, "|", $hba.model, "|", "World Wide Port Name:" $wwpn


vmhba1 | Cisco VIC FCoE HBA Driver | World Wide Port Name: 20000025b502a101
vmhba2 | Cisco VIC FCoE HBA Driver | World Wide Port Name: 20000025b502a100

12 comments to HOW TO: Find HBA WWN number on VMware vSphere ESX server

  • anonymous

    ~ # esxcfg-scsidevs -a

  • REne

    Connect-VIServer -Menu
    $vmHost = Get-VMHost
    $vmHost | Get-VMHostHba -Type FibreChannel | Select VMHost,Name,Pci,Driver, PortWorldWideName, @{name=”WWN”;Expression={“{0:x}” -f $_.PortWorldWideName}} |FT -Auto
    $vmHost =”

  • ramshackle

    What does {0:x} -f do? (I mean, I see that it formats the WWPN properly, but how does it do it?)

  • Nawal Kishor Singh

    3. Powershell script to list host name, vmhba number, HBA model / driver and World Wide Port Name (WWN):

    Hello Guys,

    can you please modifiy this script to get all info in excel sheet.

  • #===============================================================================================
    # Parameter Definitions


    # Enter vCenter Name

    # Input the ClusterName, you may enter multiple, e.g “Cluster1″,”Cluster2″,”Cluster3”


    # Function Definitions

    function Get-ScriptDirectory {
    $Invocation = (Get-Variable MyInvocation -Scope 1).Value
    Split-Path $Invocation.MyCommand.Path

    function Get-StorageAdapters
    # If the provided cluster name cannot be found, script will stop and disconnected from vCenter
    $aCluster = Get-cluster $sClusterName
    throw{“Error! Unable to find cluster: $sClusterName”}
    If ($oVI)
    Write-host “Disconnecting from vCenter $vCenterName”
    disconnect-viserver * -confirm:$false

    # Get all associated hosts to the cluster and place in an array
    $arrayESXHosts = @(Get-cluster $sClusterName | Get-VMHost)

    # Count how many hosts are in the array and loop that many times to get their storage info.
    $countHosts = $arrayESXHosts.count
    for($i = 0; $i -lt $countHosts; $i++)
    $esxHost = $arrayESXHosts[$i]

    Write-Host “Working on Host: “, $esxHost`n
    $aHBAs = Get-VMHostHba -VMHost $esxHost -Type FibreChannel

    foreach ($HBA in $aHBAs)
    $WWPN = “{0:x}” -f $HBA.PortWorldWideName
    #$WWN = $HBA.WorldWideName
    $Device = $HBA.Device
    $Model = $HBA.model
    $WWPName = $WWPN

    $out = new-object psobject
    $out | Add-Member noteproperty “ESX Host” $esxHost
    $out | Add-Member noteproperty “HBA Device” $Device
    $out | Add-Member noteproperty “HBA Model” $Model
    $out | Add-Member noteproperty “World Wide Port Name” $WWPName
    #$out | Add-Member noteproperty “World Wide Name” $WWN

    # For each host, an individual spreadsheet will be created with their data
    $array = @()
    $array += $out
    $array | Export-CSV “$sScriptPathStorage_Adapters$i.csv” -notype

    # For each hosts’ spreadsheet that were created, import back to PowerShell variable CSV
    for($i=0; $i -lt $countHosts; $i++){
    $CSV += @(Import-CSV “$sScriptPathStorage_Adapters$i.csv”)

    # Export all spreadsheet that were imported to variable CSV to a single spreadsheet
    $CSV | Export-CSV “$sScriptPathStorage_Adapters.csv” -notype

    # Remove all of the individual spreadsheets that were created for each hosts
    for($i=0; $i -lt $countHosts; $i++){
    Remove-Item “$sScriptPathStorage_Adapters$i.csv”

    # Begin Main

    Write-Host “Begin Main”

    # Load the Powercli snapin
    If(!(Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue))
    Write-host “Adding VMware Snappin”
    Add-PSSnapin VMware.VimAutomation.Core

    # Connect to VCenter Server
    Write-Host “Connecting to vCenter $vCenterName`n”
    $oVI = connect-viserver $vCenterName -Port 443 -ErrorVariable Err -ErrorAction stop

    throw (“!!!Error: Unable to connect to vCenter Server: $vCenterName!!!”)

    # Calls the function Get-ScriptDirectory
    $sScriptPath = Get-ScriptDirectory
    # calls the main function, which will get the storage adapter WWN, Device, and Model

    # If vCenter is still connected, disconnect all
    If ($oVI)
    Disconnect-Viserver * -confirm:$false
    Write-Host “Disconnected from the vCenter Server: $vCenterName”

  • Nawal Kishor Singh

    Hi Abdel,

    I checked in our production environments is workign perfectly fine. I really appreciate you.

  • Nawal Kishor Singh

    Hi All,

    In our prod environment we are using EMC and Netapp storage in VMware environment. so we are planning to decommission EMC storage and using only Netapp.

    I need powercli scripts to get any VMs that are not on Netapp storage. so that we will plan to moving the VMs to new Netapp datastore.

  • Nawal Kishor Singh

    Hi All,

    I need powercli scripts to get ssh services status on all esxi host in excel sheet.

  • Santosh


    Could you please help me to get 30 Days all VM snapshot deleted auto ?

  • tony

    Worked for me. Thanks a lot!

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>




This site uses Akismet to reduce spam. Learn how your comment data is processed.