Thursday, August 11, 2011

Collect WWN

Due to recent works on migrating a large number of servers and SAN LUNs, I threw together this small script to collect WWN numbers (see WWN on Wikipedia) from servers. Maybe it can be useful for someone else?

Save the lines below as wwn.ps1 :

## WWN version 1.1
## Script to determine HBA WWNs on remote servers (Win 2003+)
## Usage: .\wwn.ps1

Param ($servername)

$data = Get-WmiObject -namespace "root\wmi" -class MSFC_FibrePortNPIVAttributes -computer $servername

$data | select WWPN | foreach {[array]::Reverse($_.WWPN); [BitConverter]::ToUInt64($_.WWPN, 0).ToString("X") }


Azam said...

it says invalid class...
I am trying to run from win2k3 box

Jakob Bindslet said...

It says "invalid class", because the required class "MSFC_FibrePortNPIVAttributes" isn't available on the server. Most likely vause: no HBA (host adapter bus) is installed in the server.

Unknown said...

Can you please let me know the same command using WMIC? Need to run for server where Powershell is not installed

Unknown said...

It's just better to be yourself than to try to be some version of what you think the other person wants. See the link below for more info.