Get esx host CDP info: Difference between revisions

From roonics
Jump to navigation Jump to search
(Created page with "Credit to LucD from the VMware forums http://communities.vmware.com/message/977487 <pre> Get-VMHost | Sort -Property Name | %{Get-View $_.ID} | %{$esxname = $_.Name; Get-View...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 21: Line 21:


</pre>
</pre>
[[Category:vmware]]
[[Category:vsphere]]
[[Category:esxi]]
[[Category:powercli]]
[[Category:scripts]]
‎<comments />

Latest revision as of 10:04, 20 March 2022

Credit to LucD from the VMware forums http://communities.vmware.com/message/977487

Get-VMHost | Sort -Property Name | %{Get-View $_.ID} | %{$esxname = $_.Name; Get-View $_.ConfigManager.NetworkSystem} | %{
  foreach($physnic in $_.NetworkInfo.Pnic){
    $pnicInfo = $_.QueryNetworkHint($physnic.Device)
    foreach($hint in $pnicInfo){
      Write-Host $esxname $physnic.Device $hint.connectedSwitchPort.DevId $hint.connectedSwitchPort.PortId
    }
  }
}

Example output:

esxserver01 vmnic1 core-switch-01 GigabitEthernet1/0/1
esxserver02 vmnic2 core-switch-02 GigabitEthernet1/0/2
esxserver03 vmnic3 core-switch-01 GigabitEthernet1/0/2
esxserver04 vmnic4 core-switch-02 GigabitEthernet1/0/1

‎<comments />