Hi,
I'm trying to retrieve the SAN Identifier information for all HBA cards in a given list of ESX servers.So far I've tried 2 options
1)(get-view $esx.id).config.storagedevice.HostBusAdapter |?{$_.key -match "Fibre"}
Unfortunately the NodeWorldWideName returned does not match the SAN Identifier visible through VI Client
NodeWorldWideName : 2305843973627300411 (PoSH)
SAN Identifier / WWPN : 21:00:00:e0:8b:13:5a:b7 (GUI)
2) A more manual approach also fails... I tried using plink.exe & "esxcfg-mpath -l" to get HBA info (in text block)- and then Select-String to build WWPN list.
This works ok, but it ignores HBA that are not connected. (which is a problem)
FC 7:13.0 210000e08b87ca3b<->5006016810600f14 vmhba1:1:0 On active preferred
Any help, or steer on this would be greatly appreciated
That is because the PortWorldWideName property is shown in decimal format.
If you convert it to hex you will see the same string as in the VI Client
$esx = Get-VMHost -Name <ESX-hostname> | Get-View foreach($hba in $esx.Config.StorageDevice.HostBusAdapter){ if($hba.GetType().Name -eq "HostFibreChannelHba"){ $wwn = $hba.PortWorldWideName $wwnhex = "{0:x}" -f $wwn Write-Host $wwnhex } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That is because the PortWorldWideName property is shown in decimal format.
If you convert it to hex you will see the same string as in the VI Client
$esx = Get-VMHost -Name <ESX-hostname> | Get-View foreach($hba in $esx.Config.StorageDevice.HostBusAdapter){ if($hba.GetType().Name -eq "HostFibreChannelHba"){ $wwn = $hba.PortWorldWideName $wwnhex = "{0:x}" -f $wwn Write-Host $wwnhex } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Cool - you really are a legend. Thanks.
Here is a slight modification to get WWNs for all hosts in a cluster.
foreach ($esx in get-cluster <CLUSTER_NAME> | get-vmhost | get-view | sort-object name){
$esx.name
foreach($hba in $esx.Config.StorageDevice.HostBusAdapter){
if($hba.GetType().Name -eq "HostFibreChannelHba"){
$wwn = $hba.PortWorldWideName
$wwnhex = "{0:x}" -f $wwn
Write-Host $wwnhex
}
}
write-host
}
I was wondering if someone could help me gather the output of the "esxcfg-mpath -l" ? I basically want to output each path for all servers in a particular cluster...
Not even sure where to begin.
It is also possible to get a complete list.
I tried to use the folloeing procedure
Connect-VIServer $vcenter
$report = @()
foreach ($esx in get-cluster | get-vmhost | get-view | sort-object name){
$row = "" | select Name,WWN
$row.Name = $esx.name
foreach($hba in $esx.Config.StorageDevice.HostBusAdapter){
if($hba.GetType().Name -eq "HostFibreChannelHba"){
$wwn = $hba.PortWorldWideName
$wwnhex = "{0:x}" -f $wwn
$row.WWN = $wwnhex
$report += $row
}
}
$report | export-csv d:\wwn-to-host.csv -NoTypeInformation
}
But I've got only the first WWN of each server.
thanks for your help
Christian
The place where you add $row to the $report array should be at the innermost loop.
And you export the $report array outside all loops.
$report = @() foreach ($esx in get-cluster | get-vmhost | get-view | sort-object name){ foreach($hba in $esx.Config.StorageDevice.HostBusAdapter){ if($hba.GetType().Name -eq "HostFibreChannelHba"){ $row = "" | select Name,WWN $row.Name = $esx.name $wwn = $hba.PortWorldWideName $wwnhex = "{0:x}" -f $wwn $row.WWN = $wwnhex $report += $row } } } $report | export-csv d:\wwn-to-host.csv -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for your help.
That was the missed thing :smileygrin: