**Update May 07, 2012 – Use the new script here: Updated: Finding WWNs for HBAs in ESXi hosts, now with Get-VMHostHba

When building a new cluster, your storage team (or you) may need to add several hosts into the shared storage zone. It’s a pain to go to each host, configuration, storage adapters, then copy out the WWN.

With this script, you can supply a vCenter server and Cluster/Folder/Datacenter (any logical container) and it will list all the WWNs for Fibre Channel devices. But what if you don’t have vCenter stood up yet? No problem, you can also supply a list of ESX/ESXi hosts to scan.

Shawn & I built this because we have 20 hosts we need the WWNs from to provide to our storage team, and vCenter isn’t alive yet.

Our script:

The usage is pretty simple, and the switches are self explanatory:
Get-WWN.ps1 -esx_hosts ("Host1","Host2","Host3")

Get-WWN.ps1 -vc drtapw0015001 -container drtcrl0011102

Main thing is you have to use one OR the other (ESX hosts OR vCenter info), you don’t need both, so why would you try to confuse this script with it.

Also, when it prompts for credentials, I chose to use the $host.ui.PromptForCredential vs Get-Credential because $host.ui.PromptForCredential allows me to specify a window title and caption to differentiate between the vCenter login and Host login.

$host.ui.PromptForCredential("window title", "text", "username", "password")

For the third arg, you could use something like “$env:userdomain\$env:username” and it’ll populate with your current domain\user info, but I left it blank, same with password.