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 “:”}
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”
Trackbacks/Pingbacks
- Blogs Created by Daag van der Meer - […] Finding WWN’s on Windows Server 2012 Using PowerShell […]
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
why not just go simpler with
get-initiaotorport
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.
Its works very well on windows server 2012 R2 Standard. Many thanks
Cool!
it’s work. thx.
It does not work on Windows server 2016. Any help ?
Haven’t tried it on 2016 yet. Getting ready to build one out, will get back to you.
Did you try Get-InitiatorPort | Select-Object -Property PortAddress | Format-Table -AutoSize? This was added as an option for 2012 R2 and probably is the same on 2016, I haven’t been able to verify it yet.
Run the below commands
1) Get-help Get-Initiatorport
then run
2) Get-InitiatorPort
It will give the result.
can we retrieve WWNs of multiple servers at time using the above command. Can you help how we can export wwwn for multiple servers.
Get-Initiatorport command is not found
Get-InitiatorPort became available with Windows Server 2012 R2 if you are trying this with Windows Server 2012 the cmdlet will not be available.
Strange, no results but I know this host has HBAs (2012 R2 Server)
Did you try just running Get-InitiatorPort that cmdlet was first available in 2012 R2.
This command does work on Server 2016. I tried on 2 of my Servers.