VMware Cloud Community
thiag2011
Enthusiast
Enthusiast
Jump to solution

Need to get distributed switch information of a host

Hi all,

I would like to fetch the distributed switch information of a host.

With the below script am able to get the switch name, network cards added to this dvswitch and its status.

$report = @()
foreach($sw in (Get-VirtualSwitch -Distributed)){
   
$uuid = $sw.ExtensionData.Summary.Uuid
   
$sw.ExtensionData.Config.Host | %{
       
$portStates = $sw.ExtensionData.FetchDVPorts($null)
       
$esx = Get-View $_.Config.Host
       
$netSys = Get-View $esx.ConfigManager.NetworkSystem
       
$netSys.NetworkConfig.ProxySwitch | where {$_.Uuid -eq $uuid} | %{
           
foreach($pnicSpec in $_.Spec.Backing.PnicSpec){
               
$row = "" | Select Host,dvSwitch,PNic,PortLinkUp
               
$row.Host = $esx.Name
               
$row.dvSwitch = $sw.Name
               
$row.PNic = $pnicSPec.PnicDevice
               
$row.PortLinkUp = ($portStates | where{$_.Key -eq $pnicSPec.UplinkPortKey}).State.RunTimeInfo.LinkUp
               
$report += $row
            }
        }
    }
}

$report


But i would like to get the physical switch information(name of the physical switch and the port information of each vmnic connected to this host. Please help to fetch the same.

Note:

CDP information is enabled.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Since you have the PNICs, it would be a matter of using a script like Re: How to get CDP values from Cisco Switch? to get the CDP info.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Since you have the PNICs, it would be a matter of using a script like Re: How to get CDP values from Cisco Switch? to get the CDP info.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
thiag2011
Enthusiast
Enthusiast
Jump to solution

Thanks a lot LucD, it helped!!!!

Reply
0 Kudos