Pages

Saturday, November 2, 2013

Finding a virtual machine in VMware vSphere by the MAC address

I recently had to troubleshoot an issue within a Citrix XenDesktop environment hosted on VMware vSphere 5.1 where one of the DDC (Desktop Delivery Controllers) appeared to have an IP conflict with another VM:

image

So the good news is that I have the MAC address of the conflicting device: 00-50-56-91-33-B4 but the bad news is that when I look this MAC address on a MAC finder site such as:

http://www.coffer.com/mac_find/

image

… I get the following result:

image

Great, it’s a VMware device and I have over hundreds of VMs hosted.

As there isn’t a way to list VMs or search via MAC addresses in the vSphere Client, I had to resort to using PowerShell.  I’m not much of an expert with PowerShell cmdlets since I don’t really use them on a daily basis so I dug up one of my old posts:

Bulk changing port group settings for virtual machines in vSphere 5 with vSphere PowerCLI
http://terenceluk.blogspot.com/2012/02/bulk-changing-port-group-settings-for.html

… which gave me the cmdlet:

Get-VM -Location “XenDesktop VDI Master Images” | Get-NetworkAdapter

The cmdlet gave me a starting point to

Get-VM | Get-NetworkAdapter | Where {$_.MacAddress -eq “00:50:56:91:33:b4”}

image

Unfortunately as shown in the screenshot above, this cmdlet gives me all of the network details of the offending VM but not the name of it.  The way around this is to use the Format-List (or FL for the short form) cmdlet to list all of the properties for the VM including the name as shown here:

image

Note that the name of the VM is the value for Parent.

8 comments:

Unknown said...

Hey Man!!!

Thank you very much for this post!
It help me a lot!!

Anonymous said...

Worked perfectly for me - found a VM that had a different name than it's DNS name. Thanks for the post!

Anonymous said...

Thanks a lot for posting this!
It helped me a lot.

Arjun said...

Thanks much, it worked for me. Great Help....!!!!

Greg said...

Appreciate the article. It was quite helpful.

Carlos Garcia said...

I resolved the issue also from a different angle:

Get-View -ViewType VirtualMachine | ?{ $_.Guest.IPAddress -eq "1.2.3.4 " }

since both commands pointed to the same VM I knew who to blame :D

Zia Mulla said...

Definitely a great article. We had this problem in our lab and were going in Circles.
Thanks for putting it together.

Zia

Srikanth said...

Really Awesome.