WWNN (World Wide Node Name) and WWPN (World Wide Port Name) are unique identifiers used in Fibre Channel and Fibre Channel over Ethernet (FCoE) storage networks.

One can read them on the UI for sure, but reading using a script will help to perform some automation tasks.

The process of reading it is explained below:

  • Connect to your vCenter(s). You can use the PowerCLI directly, but using a wrapper will help you connect and work with multiple vCenters. This wrapper is called Connect-vCenter
  • Get all VMHosts that are in Connected or Maintenance state.
$VMHosts = Get-VMHost -State Connected,Maintenance
  • Going for each VMhost and reading the VMHostHba
# Empty array to store the infromation
$AllVMHostHBAInfo = @()

# Loop for each object
foreach($VMHost in $VMhosts){
    # For each host get collect the information and store it to the variable $VMHostHBAs
    # like Device, Status, Driver, Model
    # also convert WWPN and WWNN decimal format to a more readable value
    $VMHostHBAs = $VMHost | Get-VMHostHba -Type FibreChannel | Select-Object Device, Status, Driver, Model, @{n='WWPN';e={$wwpn = "{0:x}" -f $_.PortWorldWideName; (0..7 | ForEach-Object {$wwpn.Substring($_*2,2)})}}, @{n='WWNN';e={$wwnn = "{0:x}" -f $_.PortWorldWideName; (0..7 | ForEach-Object {$wwnn.Substring($_*2,2)})}}

    # Foreach Hba for that host
    foreach($VMHostHBA in $VMHostHBAs){
        # Create a hash-table and store the information
        # foreach host, and then for each Hba in that host
        # I used [ordered] - as I want the infromation below to be in this order when it is generated
        $props = [ordered]@{}
        $props.'vCenter' = $VMHost.vCenter
        $props.'Cluster' = $VMHost.Parent.Name
        $props.'VMHost' = $VMHost.Name
        $props.'Device' = $VMHostHBA.Device
        $props.'Status' = $VMHostHBA.Status
        $props.'Driver' = $VMHostHBA.Driver
        $props.'Model' = $VMHostHBA.Model
        $props.'WWPN' = $VMHostHBA.WWPN
        $props.'WWNN' = $VMHostHBA.WWNN

        # Collect and store the inforamtion in to the Emtpy array that was created above
        $AllVMHostHBAInfo += New-Object -TypeName PSCustomObject -Property $Props
    }
}

The result will look like this. Of course the data in the picture below is obfuscated.

The real data that will be generated on your environment will be used on scripts to perform other tasks, or as reporting.

Last but not least, you can create a function which can be used by anyone in your team. Add this function your PS module. It is going to look like this:

The function:

function Read-HBAFCWWPNandWWNNInfo {
    param($VMHost)

    # Connect on all vCenters
    Connect-vCenter

    # Empty array to store the infromation
    $AllVMHostHBAInfo = @()

    # Loop for each object
    foreach($VMHost in $VMhosts){
        # For each host get collect the information and store it to the variable $VMHostHBAs
        # like Device, Status, Driver, Model
        # also convert WWPN and WWNN decimal format to a more readable value
        $VMHostHBAs = $VMHost | Get-VMHostHba -Type FibreChannel | Select-Object Device, Status, Driver, Model, @{n='WWPN';e={$wwpn = "{0:x}" -f $_.PortWorldWideName; (0..7 | ForEach-Object {$wwpn.Substring($_*2,2)})}}, @{n='WWNN';e={$wwnn = "{0:x}" -f $_.PortWorldWideName; (0..7 | ForEach-Object {$wwnn.Substring($_*2,2)})}}

        # Foreach Hba for that host
        foreach($VMHostHBA in $VMHostHBAs){
            # Create a hash-table and store the information
            # foreach host, and then for each Hba in that host
            # I used [ordered] - as I want the infromation below to be in this order when it is generated
            $props = [ordered]@{}
            $props.'vCenter' = $VMHost.vCenter
            $props.'Cluster' = $VMHost.Parent.Name
            $props.'VMHost' = $VMHost.Name
            $props.'Device' = $VMHostHBA.Device
            $props.'Status' = $VMHostHBA.Status
            $props.'Driver' = $VMHostHBA.Driver
            $props.'Model' = $VMHostHBA.Model
            $props.'WWPN' = $VMHostHBA.WWPN
            $props.'WWNN' = $VMHostHBA.WWNN

            # Collect and store the inforamtion in to the Emtpy array that was created above
            $AllVMHostHBAInfo += New-Object -TypeName PSCustomObject -Property $Props
        }
    }
    return $AllVMHostHBAInfo
}
0
0