Get VM name with specific MAC Address

-Recently I got a request to get a virtual machine (vm) name using only the network interface MAC Address.

After search for some scripts I could not find one that really worked for me so I put my brain to work and this is what I came up:

[sourcecode language=”powershell”]
get-vm | get-networkadapter | Where-Object { $_.macaddress -eq "00:50:56:XX:XX:XX"} | select parent, macaddress
[/sourcecode]

A brief description on how it’s working

get-vm -> gets all VMs on the vSphere server.

get-netwrokadapter -> gets the nertwork adapter properties as name, type, macaddress…

$_.macaddress -eq -> for each networkadapter it is going to compare the MACs and if they are equal it is going to be printed out

The output should be something like this:

55a15d7e5c007131


Posted

in

, , ,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *