Just a quick how-to on using VMware PowerCLI to get All Virtual Machine (VM) MAC addresses, host VM is registered to and VM name.

I was trying to track down a VM and did not want to go through 100 VMs just to find out what MAC address its NICs had. I knew the IP address this particular mac address was mapped to and found that out using “show arp” command on cisco router:
#show arp

ProtocolAddressAge(min)Hardware AddressTypeInterface
Internet192.168.1.20780050.56b8.65a1ARPAGigabitEthernet0/0

Once I knew the MAC address was in fact a VM (0050.56xx.xxxx mac addresses are used by VMware for its virtual NICs), I opened up Windows Powershell and executed this command (you will need PowerCLI installed and loaded):

PS C:\Windows\system32> Get-VM | `
>> Select-Object -Property Name,@{N=”MacAdresses”;E={$_.NetworkAdapters | ForEach-Object {$_.MacAddress}}},VMHost
>>

NameMacAddressesVMHost
myTestVM{00:50:56:b8:65:a1, 00:50:56:86:00:0b}192.168.1.222

Both (from cisco router ARP and VMware PowerCLI) show same MAC address mapped to myTestVM on host 192.168.1.222. Now you can safely disable that NIC or change IP address on it (in case of duplicate IP issues, etc.)

On older version of powerCLI, you may get this warning message:
WARNING: ‘NetworkAdapters’ property is obsolete. Use ‘Get-NetworkAdapter’ cmdlet instead.

So, be sure to change the command if necessary. Your setup and deployment maybe different from mine so make sure you are aware of the risks and I take no responsibility for your wrong doing.

If you have any questions on this or other tutorials, post in our Virtualization Forum.

Comments are closed.