VMware Cloud Community
markdjones82
Expert
Expert
Jump to solution

Get-VMhostHBA WWN

All,

  I am running the following command to try and gather all the WWN's for my hosts, but the outputted number does not equal what I have listed for the Emulex of our blades.  Any reason this number doesn't seem to match up?

Get-VMHostHBA -type FibreChannel | Select VMHost,Device,PortWorldWideName

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The WWN property doesn't display in hex but in decimal.

Try it like this

Get-VMHostHBA -Type FibreChannel | 
Select VMHost,Device,@{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

The WWN property doesn't display in hex but in decimal.

Try it like this

Get-VMHostHBA -Type FibreChannel | 
Select VMHost,Device,@{N="WWN";E={"{0:X}" -f $_.PortWorldWideName}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
markdjones82
Expert
Expert
Jump to solution

Found the earlier postings and came up with this:

$hosthba = Get-VMHostHBA -type FibreChannel | Select VMHost,Device,PortWorldWideName

foreach ($hostwwn in $hosthba){

$hostwwn.PortWorldWideName = "{0:x}" -f $hostwwn.PortWorldWideName

}

$hosthba | Sort VMHost,Device | export-csv hbainfo.csv -notypeinformation

Yours is much more elegant than mine as usual!

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
Reply
0 Kudos
MikeErter
Enthusiast
Enthusiast
Jump to solution

What is the "{0:x}" -f in your calculated property doing?  I see that it's formatting the WWPN in hex, but what is that formatting trick called in Powershell?

Reply
0 Kudos
markdjones82
Expert
Expert
Jump to solution

Mike, it is a .net formatting technique.  Here is a good article that explains it:

http://technet.microsoft.com/en-us/library/ee692795.aspx

0 is the index and x is for hexadecimel.

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
Reply
0 Kudos