25 Apr 2012

Powershell one-liner to find vSphere guest by MAC address

Somebody has stolen an IP address which belongs to one of your vSphere guests and you have an IP conflict reported in Windows Event Log? Just note the suspicious MAC and execute the following statement within vSphere PowerCLI

Get-VM | Get-NetworkAdapter | ? {$_.MacAddress -match '00:50:56:AF:00:61'} | % {get-vm -Id (($_.Id).split('/')[0])}