VMware Cloud Community
RoyalFlash
Enthusiast
Enthusiast

Get ESXi Host Uplinks on Virtual Switches with PowerCLI

Hi all,

how can I get the number of Uplinks for each Standard/Distributed vSwitch on ESXi Hosts with PowerCLI?

 

ESXiHostVirtualSwitchesUplinks.jpg

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

Try something like this

Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
  $netSys = Get-View -Id $esx.ExtensionData.ConfigManager.NetworkSystem
  $netsys.NetworkInfo.Vswitch |
  ForEach-Object -Process {
    New-Object -TypeName PSObject -Property ([ordered]@{
        VMHost = $esx.Name
        Name = $_.Name
        Type = 'Standard vSwitch'
        Uplinks = $_.Pnic.Count
      })
  }
  if ($netsys.NetworkInfo.ProxySwitch) {
    $netsys.NetworkInfo.ProxySwitch |
    ForEach-Object -Process {
      New-Object -TypeName PSObject -Property ([ordered]@{
          VMHost = $esx.Name
          Name = $_.DvsName
          Type = 'Distributed vSwitch'
          Uplinks = $_.UplinkPort.Count
        })
    }
  }
}


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

Reply
0 Kudos
RoyalFlash
Enthusiast
Enthusiast

Thanks LucD!! I will check it

Very good support here! 🙂

 

Reply
0 Kudos