powershell command for wwn

Powershell Command for WWN

WWN (World Wide Name): Its a Unique identifier we use in SAN (Storage Area Network) technologies, sometimes we require to find WWN to share it with SAN team to assign LUN (Logical Unit Number) on that particular server having HBA card.

Below are some powershell command variants.

Command to display only World Wide Name

gwmi -Namespace root\wmi -Class msfc_fcadapterhbaattributes | %{($_.nodewwn| %{“{0:X2}” -f $_}) -join “:” }

 

Command to display Word Wide Name, Firmware Version, Driver Version, Rom Version in table format.

gwmi -Namespace root\wmi -Class msfc_fcadapterhbaattributes | add-member -passthru -type scriptproperty -name wwn -value {$this | %{ ($_.nodewwn | %{“{0:X2}” -f $_}) -join “:”} } | format-table wwn, Model, OptionRomVersion,FirmwareVersion,DriverVersion -AutoSize

Cmdlets meaning and its usage

Gwmi is a alias of Get-WmiObject and using root\wmi namespace to access the class msfc_fcadapterhbaattributes having various properties like Model, Firmware version, Rom Version etc…

Add-member: this cmdlet lets you add a custom member to an existing instance.

Passthru: The PassThru parameter lets you request output from Add-member cmdlet otherwise no output by default.

% is a alias of foreach-object, you can see two foreach loops are added, first for loop is used to extract all decimal values from the NodeWWN object and second foreach loop to convert each decimal value to hexadecimal value.

Conversion from decimal to hexadecimal is done through “{0:X2}” -f $_

Format-table cmdlet is used display items in table format and removed unwanted space from each column with -AutoSize parameter.

Leave a Reply