While this same information is already scattered around the internet, I wanted to present this in a format that is hopefully easily usable by someone that is not powershell savvy, and needs a quick way to track down duplicate MACs.
Prerequisites
- Windows 7,8,10 workstation
- Powershell 3.0 or higher
- Admin permission to vcenter or ESXi host
- Admin permission on local Windows workstation
- Windows workstation access to internet
Initial setup/config:
Launch Windows powershell with admin privilege.
Install-Module -Name VMware.PowerCLI (say yes when prompted to ‘Are you sure’)
Set-PowerCLIConfiguration -InvalidCertificateAction:Ignore (Say Yes, this allows powershell to ignore selfsigned certificate alerts from vcenter)
Set-PowerCLIConfiguration -Scope User -ParticipateInCeip $false (if you don’t set this to $false or $true, you will get nagged every time you load the Vmware PowerCLI module)
Running commands
import-module -name VMware.PowerCLi
Connect-VIserver -Server x.x.x.x -user administrator@vsphere.local -Password xxxxxxxxxx
Get-View -Viewtype VirtualMachine -Property Name, Config.Hardware.Device | `Select name, @{n="MAC(s)"; e={($_.Config.Hardware.Device | ?{($_ -is [VMware.Vim.VirtualEthernetCard])} | %{$_.MacAddress}) -join ","}}
Any instances of 2 or more MAC Addresses will be listed.
Additional command
Get-View -Viewtype VirtualMachine -Property Name, Config.Hardware.Device | `Select name, @{n="MAC(s)"; e={($_.Config.Hardware.Device | ?{($_ -is [VMware.Vim.VirtualEthernetCard])} | %{$_.MacAddress}) -join ","}} | `Export-Csv c:\temp\guestVM-maclist.csv -UseCulture -NoTypeInformation
Exports list of guestVMs and all MAC addresses associate with the guestVM NICs to .csv file.
Hope this helps.
Kirk...