How do I go about sending a query to vcenter and have it output a text file that contains all the mac addresses for all of my vms plus vm name. Any help will be most welcome. thanks
Hello, RadarG-
You can achieve this pretty quickly with something like:
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\VMMACsInfo.csv -UseCulture -NoTypeInformation
This basically came from my vNugglets.com post "Find VM by NIC MAC Address with PowerShell -- Fast Like!". If you are just wanting an ivnventory list of your VMs' MAC addresses, this will do fine. But, if you are looking for a VM by MAC address, or maybe are looking for duplicates, there are other, easier ways.
I recently made three (3) MAC address related posts (see them at the MAC Address tag at vNugglets). There are for finding VMs by MAC address, finding duplicate MAC addresses, and setting MAC addresses on VMs.
Enjoy.
Hello, RadarG-
You can achieve this pretty quickly with something like:
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\VMMACsInfo.csv -UseCulture -NoTypeInformation
This basically came from my vNugglets.com post "Find VM by NIC MAC Address with PowerShell -- Fast Like!". If you are just wanting an ivnventory list of your VMs' MAC addresses, this will do fine. But, if you are looking for a VM by MAC address, or maybe are looking for duplicates, there are other, easier ways.
I recently made three (3) MAC address related posts (see them at the MAC Address tag at vNugglets). There are for finding VMs by MAC address, finding duplicate MAC addresses, and setting MAC addresses on VMs.
Enjoy.
hmm ok so will this output the csv and list both the macs and vm names?
So I jut log into the vma and connect to my center and run this command.
This is powershell, so it requires a windows machine with powershell/powercli installed, not the VMA.
If you are using vSphere Distributed Switch:
RadarG wrote:
How do I go about sending a query to vcenter and have it output a text file that contains all the mac addresses for all of my vms plus vm name. Any help will be most welcome. thanks
MUCH easier way, it's graphical and exportable and it's FREE!
RV Tools, nothing better...