I’ve been following William Lam‘s VMTN account in my RSS reader for a while as William regularly releases useful scripts. Lately he has been pumping iron and releasing new scripts or new versions of scripts on an almost daily basis. One of the most useful scripts that William released lately is “getvSwitchMacTable.pl”. Make sure to add William to you RSS reader or just follow him on twitter.
This script allows you to dump information about your vSwitche(s) pertaining to the VM(s) that are attached, the portgroups in which the VM(s) are attached to and the corresponding MAC Address that maps to the portgroup/vswitch
You can specify a specific Cluster, Datacenter or if execute against vCenter without options, it will extract ALL VMs or you execute against an individual ESX(i).