thiag2011
Enthusiast
Enthusiast

Need to get distributed switch information of a host

Jump to solution

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.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

0 Kudos
2 Replies
LucD
Leadership
Leadership

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

0 Kudos
thiag2011
Enthusiast
Enthusiast

Thanks a lot LucD, it helped!!!!

0 Kudos