PowerCLI function to grab WWPN’s

PowerCLI function to grab WWPN’s

Why?

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


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

process
{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.