How to use VMware PowerCLI to get All VM Mac Addresses?

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
[table id=4 /]
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
[table id=5 /]
Both (from cisco router ARP and VMware PowerCLI) show same MAC address mapped to myTestVM on host 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.