search
top

Finding WWN’s on Windows Server 2012 Using PowerShell

With a single command you can retrieve WWN’s on Windows Server 2012 R2 using PowerShell.

Open the PowerShell command and type:

Get-WmiObject -class MSFC_FCAdapterHBAAttributes -namespace “root\WMI” | ForEach-Object {(($_.NodeWWN) | ForEach-Object {“{0:x}” -f $_}) -join “:”}

2012wwn

And that is all there is to it. Simple and fast using PowerShell.

Update: I have been been made aware of another way to get the WWN on Windows 2012 R2 with a cmdlet called get-initiatorport which was added to Windows Server 2012 R2. This is a much cleaner way of retrieving the WWN information instead of the WMI call.

 

PS C:\> Get-InitiatorPort

InstanceName NodeAddress PortAddress ConnectionType
------------ ----------- ----------- --------------
PCI\VEN_10DF&DEV_F100&SUBS... 20000090fa56b930 10000090fa56b930 Fibre Channel
PCI\VEN_10DF&DEV_F100&SUBS... 20000090fa56b931 10000090fa56b931 Fibre Channel

You can also filter the display and just get the PortAddress

PS C:\> Get-InitiatorPort | Select-Object -Property PortAddress | Format-Table -AutoSize

PortAddress
-----------
10000090fa56b930
10000090fa56b931

More information on get-initiatorport and many other storage related cmdlets can be found here!

 

16 Responses to “Finding WWN’s on Windows Server 2012 Using PowerShell”

  1. pham says:

    how did you get the MSFC_FCAdapterHBAAttributes on windows 2012 server.
    running
    gwmi -list -namespace root\wmi | Sort-Object Name
    does not give me the class you defined
    OS Windows 2012 R2 Datacenter

  2. thedeamon says:

    why not just go simpler with

    get-initiaotorport

    • newlife007 says:

      Awesome, didn’t know that cmdlet existed in 2012 R2. Thanks for the tip I have added it to the post. Would be cooler if Microsoft added the ability to upgrade PowerShell on 2008 R2 and get the new cmdlet. Tried updating to PowerShell 4 with .NET 4.51 and didn’y appear.

  3. ALi says:

    Its works very well on windows server 2012 R2 Standard. Many thanks

  4. Sajir says:

    Cool!

  5. Ivan says:

    it’s work. thx.

  6. Pushpeen says:

    It does not work on Windows server 2016. Any help ?

  7. Sreenivas says:

    can we retrieve WWNs of multiple servers at time using the above command. Can you help how we can export wwwn for multiple servers.

  8. Yuvi says:

    Get-Initiatorport command is not found

  9. Jim Staszko says:

    Strange, no results but I know this host has HBAs (2012 R2 Server)

  10. DeLeon Cannedy says:

    This command does work on Server 2016. I tried on 2 of my Servers.

Trackbacks/Pingbacks

  1. Blogs Created by Daag van der Meer - […] Finding WWN’s on Windows Server 2012 Using PowerShell […]

Leave a Reply

Your email address will not be published. Required fields are marked *

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

top