I am trying to come up with a way to get a list of all VMs in an environemnt with their adapters mac address. I'm trying to hunt down a possible duplicate mac address in a large virtual environment
what I have so far:
Get-VM | Get-View | Select-Object -Property Name, @{N=”MAC”;E={$_.MacAddress}} | Export-Csv C:\filename.csv -NoTypeInformation
This will get me the adapter name and the mac address but not the VM name. Can someone help me with the rest? thanks.
I don’t know what you consider large? We are hosting around 5k+ virtual servers and a few farms. If running on production system could take some major time
Search it all - Full dump
save as FullDumpMac.ps1
# FULL DUMP VM/Mac
$fullDump = Get-VM | ForEach-Object {
$VM = $_
if ($VM) {
$VM.Guest.Nics | Select-Object -Property @{N=”VM”;E={$VM.Name}},Macaddress
}
}
$fullDump | Export-Csv report.csv -NoTypeInformation -UseCulture
Folder search
#Notice I am using a folder search from adjust to script to not have folder
$Dump = Get-Folder -Name demo | Get-VM | ForEach-Object {
$VM = $_
if ($VM) {
$VM.Guest.Nics | Select-Object -Property @{N=”VM”;E={$VM.Name}},Macaddress
}
}
$Dump | Export-Csv report.csv -NoTypeInformation -UseCulture
Best of Luck,
(A}{E - Kansas City)
[Wisdom comes from experience, and experience comes from bad decisions. ]
Take a look at my blog post How to use VMware vSphere PowerCLI to find the MAC addresses of a virtual machine.
I don’t know what you consider large? We are hosting around 5k+ virtual servers and a few farms. If running on production system could take some major time
Search it all - Full dump
save as FullDumpMac.ps1
# FULL DUMP VM/Mac
$fullDump = Get-VM | ForEach-Object {
$VM = $_
if ($VM) {
$VM.Guest.Nics | Select-Object -Property @{N=”VM”;E={$VM.Name}},Macaddress
}
}
$fullDump | Export-Csv report.csv -NoTypeInformation -UseCulture
Folder search
#Notice I am using a folder search from adjust to script to not have folder
$Dump = Get-Folder -Name demo | Get-VM | ForEach-Object {
$VM = $_
if ($VM) {
$VM.Guest.Nics | Select-Object -Property @{N=”VM”;E={$VM.Name}},Macaddress
}
}
$Dump | Export-Csv report.csv -NoTypeInformation -UseCulture
Best of Luck,
(A}{E - Kansas City)
[Wisdom comes from experience, and experience comes from bad decisions. ]