PowerShell/ PowerCLI to identify physical switch ports that VMware ESXi Virtual Switches are connected to, as reported by LLDP. Useful for checking patching of a vSphere environment.
This function returns a table containing the hostname(s), vmnic IDs, virtual distributed switch ids, physical switch name (or MAC address if that's not reported) and port identifiers, and the visible VLAN tags.
HostName Device SwitchName SwitchPort VirtualSwitch VLANs
-------- ------ ---------- ---------- ------------- -----
myesxihost1.example.com vmnic0 MY-SWITCH-01-B 1/1/1 vDS-Data01 1 3 6 78
myesxihost1.example.com vmnic1 MY-SWITCH-01-A 1/1/2 vDS-Data02 2 4 75 76
myesxihost2.example.com vmnic4 00:01:02:03:04:05 4:19 vDS-Data01 1 3 6 78