VMware Cloud Community
admin
Immortal
Immortal
Jump to solution

FC Target Addresses

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?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
8 Replies
BigBubba
Contributor
Contributor
Jump to solution

I would like to know the same thing. I believe it has something to do with: IScsiHbaTarget. You can take a look at more details here:

LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
admin
Immortal
Immortal
Jump to solution

Worked perfectly,

Thanks so much this is a big help!

0 Kudos
admin
Immortal
Immortal
Jump to solution

LucD,

Last question I promise, how can I make it iterate through cluster of ESX hosts? Obviously my PS skills are minimal.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
andreasbrunner
Contributor
Contributor
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
andreasbrunner
Contributor
Contributor
Jump to solution

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

0 Kudos