Does anyone know how to use Powershell to retrieve the FC SAN target addresses as you would see in the Manage Paths property box of a vSphere client?
The vSphere client display the Node and the Port WWN (hence the 2 sets of IDs).
This adapted version gives both WWNs.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The vSphere client display the Node and the Port WWN (hence the 2 sets of IDs).
This adapted version gives both WWNs.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Worked perfectly,
Thanks so much this is a big help!
LucD,
Last question I promise, how can I make it iterate through cluster of ESX hosts? Obviously my PS skills are minimal.
Here you go
$clusterName = "ITSDEV" $report = @() Get-Cluster -Name $clusterName | Get-VMHost | %{ $hbaTab = @{} $lunTab = @{} $esx = $_ | Get-View $esx.Config.StorageDevice.HostBusAdapter | %{ $hbaTab.Add($_.Key, $_.Device) } $esx.Config.StorageDevice.ScsiLun | %{ $lunTab.Add($_.Key, $_.CanonicalName) } foreach($hba in $esx.Config.StorageDevice.ScsiTopology.Adapter){ if($hba.Adapter -like "*FibreChannelHba*"){ foreach($tgt in $hba.Target){ foreach($lun in $tgt.Lun){ $row = "" | Select ESXname, hbaName, Lun, NodeWWN,PortWWN $row.ESXname = $esx.Name $row.hbaName = $hbaTab[$hba.Adapter] $row.Lun = $lunTab[$lun.ScsiLun] $row.NodeWWN = "{0:x}" -f $tgt.Transport.NodeWorldWideName $row.PortWWN = "{0:x}" -f $tgt.Transport.PortWorldWideName $report += $row } } } } } $report | Sort-Object -Property ESXname, hbaName,Lun,NodeWWN -Unique
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm getting an error with the following line:
$row.hbaName = $hbaTab[http://$hba.Adapter|http://$hba.Adapter]
23 Zeichen:49
+ $row.hbaName = $hbaTab[ <<<< http://$hba.Adapter|http://$hba.Adapter]
+ CategoryInfo : ParserError: ([:String) [], ParseException
+ FullyQualifiedErrorId : MissingArrayIndexExpression
regards
Andreas
The old forum SW had a problem with square brackets.
I corrected the script.
With the new forum SW you should be able to copy/paste the script correctly.
As a test, there shouldn't be any http: statements in the script.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
thanks a lot. It worked now.
Just fyi: The same issue is also in the script presented under:
http://communities.vmware.com/thread/268999?tstart=300
regards
Andreas