PowerCLI function to grab WWPN’s

PowerCLI function to grab WWPN’s


As speaking with our storage administrators they sometimes ask for the exact WWPN so they are sure to remove the right LUNs etc. Because it’s a few mouseclicks to find the WWPN and it’s hard to copy, I managed to get it done by a little PowerCLI function below.


function Get-WWN{
Get WWN name from ESX hosts
This scripts gathers the WWN portname from ESX hosts
Authors: Patrick Heijmann
Specify the VMhosts To gather the ports from
PS> get-wwn -VMhosts ESXhost001
PS> Get-Cluster -Name *|get-vmhost|Get-WWN
PS> Get-vmhost *|Get-WWN
Param (
Valuefrompipeline = $true,
ParameterSetName = "VMhosts",
Mandatory = $true,
HelpMessage = "Enter Host name")]

{foreach ($vmhost in $vmhosts){Write-Host -foregroundcolor green "Server: " $vmhost
$hbas = Get-VMHostHba -vmhost $vmhost -Type FibreChannel
foreach ($hba in $hbas){$wwpn = "{0:x}" -f $hba.PortWorldWideName
Write-Host -foregroundcolor green `t "World Wide Port Name:" $wwpn}

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.