When setting up connectivity between SANs and hosts knowing the HBA information is important. With Pure Storage the WWNs are automatically discovered if zoned properly to the fabric. So from the GUI you will see the WWNs. But who do those WWNs belong to? Knowing the associated ports to host is important for setting up all the individual hosts with proper pathing.
But first a question, “why use Get-WmiObject when there is the easy way using Get-InitiatorPort?” Well duh, because WMI is cooler. With the built in cmdlet, Get-InitiatorPort, you can retrieve the below which provides all the details needed.
PS C:\Users\Administrator.MSLAB\Desktop\github\powershell-toolkit> Get-InitiatorPort InstanceName NodeAddress PortAddress ConnectionType ------------ ----------- ----------- -------------- PCI\VEN_1137&DEV_0045&SUBSYS_00841137&REV_A2\0025B5FFFF22003F00_0 20000025b544000e 20000025b522003f Fibre Channel PCI\VEN_1137&DEV_0045&SUBSYS_00841137&REV_A2\0025B5FFFF22000F00_0 20000025b544000e 20000025b522000f Fibre Channel PCI\VEN_1137&DEV_0045&SUBSYS_00841137&REV_A2\0025B5FFFF66003F00_0 20000025b544000e 20000025b566003f Fibre Channel PCI\VEN_1137&DEV_0045&SUBSYS_00841137&REV_A2\0025B5FFFF66000F00_0 20000025b544000e 20000025b566000f Fibre Channel
Using Windows Management Instrumentation (WMI) there are a lot of other properties that can be queried. Below is an example of when I setup the initial lab environment at Pure Storage for working on Microsoft solutions.
From November 27.2013 —–
I was setting up a new Pure Storage FA-420 array this past week and needed the Host Bus Adapter (HBA) information, specifically the WWNodeName and WWPortName for the QLogic 2562, so I put together this PowerShell that provides all the details. Currently the script takes a single server name and should be run on the server that has the HBA installed. This was a quick solution and I wanted to get this posted but I’ll be tweaking the script to handle multiple servers and different output options.
function Get-HBAInfo { [CmdletBinding()] Param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, Position=0)] $ComputerName ) Begin { $Namespace = "root\WMI" } Process { $port = Get-WmiObject -Class MSFC_FibrePortHBAAttributes -Namespace $Namespace @PSBoundParameters $hbas = Get-WmiObject -Class MSFC_FCAdapterHBAAttributes -Namespace $Namespace @PSBoundParameters $hbaProp = $hbas | Get-Member -MemberType Property, AliasProperty | Select -ExpandProperty name | ? {$_ -notlike "__*"} $hbas = $hbas | Select $hbaProp $hbas | %{ $_.NodeWWN = ((($_.NodeWWN) | % {"{0:x2}" -f $_}) -join ":").ToUpper() } ForEach($hba in $hbas) { Add-Member -MemberType NoteProperty -InputObject $hba -Name FabricName -Value ( ($port |? { $_.instancename -eq $hba.instancename}).attributes | ` Select ` @{Name='Fabric Name';Expression={(($_.fabricname | % {"{0:x2}" -f $_}) -join ":").ToUpper()}}, ` @{Name='Port WWN';Expression={(($_.PortWWN | % {"{0:x2}" -f $_}) -join ":").ToUpper()}} ) -passThru } } } Get-HBAInfo $env:COMPUTERNAME
For formatting using the OutGridView, Format-Table or output to a file using Out-File.
Thanks,
Barkz
I’m trying to get more information out of the Fibre Channel Adapters on Windows Server 2016.
Can you help please?
Hi Kevin —
What additional information are you looking for?
Thanks//barkz
What are the meanings of portstate attribute while you get wmi information from MSFC_FibrePortHBAAttributes class. There are 2 , 6 and maybe some other values but nowhere says what do these numbers mean.
Hi Zafer —
Check this link, https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/hbapiwmi/ns-hbapiwmi-_msfc_hbaportattributesresults. This provide the PortState info. Now mapping 2, 6, etc. should go from first attribute at 0 through 7.
PortState
Contains the state of the port indicated by PortWWN. This member must have one of the following values:
Value Meaning
HBA_PORTSTATE_UNKNOWN Unknown.
HBA_PORTSTATE_ONLINE Operational.
HBA_PORTSTATE_OFFLINE User Offline
HBA_PORTSTATE_BYPASSED Bypassed.
HBA_PORTSTATE_DIAGNOSTICS In diagnostics mode.
HBA_PORTSTATE_LINKDOWN Link Down
HBA_PORTSTATE_ERROR Port Error.
HBA_PORTSTATE_LOOPBACK Loopback.
HTH, Barkz
How to run this script for remote computers?
Hi Rakesh —
By default the Get-HBAInfo cmdlet uses the -ComputerName parameter with $env:COMPUTERNAME. Instead of just running the cmdlet use:
Get-HBAInfo -ComputerName [remote_computername]
HTH — Barkz
Hi, Port Address required on remote computer along with server name
Hi Barkz,
I am not able to run the cmdlet for remote servers using the method you suggested above