?
Solved

script to find mac addresess

Posted on 2011-10-27
18
Medium Priority
?
765 Views
Last Modified: 2012-05-12
hi guys

another one from me :-)

im trying to find out all the mac addresses in our v centre environment. i have found a script online to do this
http://vnugglets.com/2011/08/dev-find-duplicate-vm-nic-mac-addresses.html

i have saved this as  a cmd file - how do i run this against a vcenter instance ???
0
Comment
Question by:mikeleahy
  • 7
  • 7
  • 3
17 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 37037066
This is a powershell script and it needs the PowerCLI commandlets installed from VMware to use it. Ther are free
0
 

Author Comment

by:mikeleahy
ID: 37037271
hwo do i do this??
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 37037334
On a server running your VCenter you need to download and install powercli from vmware
http://www.vmware.com/go/powercli&ei=bEmpTo_XF8WBhQfisa2lDg&usg=AFQjCNFddkbqT43ZTSqBGo7UBPzAQnwPPg

Once installed open Powershell with PowerCli and copy/paste that script you had to run it
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 124

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE^2) earned 1000 total points
ID: 37037423
I would recommend and use the VMware Community Pack, this should be part of your VMware Admiistration Toolkit. The VMware Community Pack includes all the Scripts around on the internet, in one GUI Package for you to use. This already includes the ability to report on Virtual Machines, and show Mac Addresses, reports can be exported as HTML, CSV and XML.

 Show MAC Addresses using PowerCLI, PowerGUI
http://www.virtu-al.net/featured-scripts/vmware-powerpack/

To use this you will need the

PowerCLI and PowerGUI

VMware also recommends the use of PowerCLI, which is PowerShell interface with vSphere-specific additions.

PowerCLI  download
http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli

One of the simplest PowerCLI examples, and something which is actually extremely useful on its own, is the Get-VM cmdlet. Which lists VMs.

PowerCLI can be a bit overwhelming to use,  But it can be enhanced with a nice toolset and a library of preconfigured scripts to jump-start your mass changes, which is possible with PowerGUI

PowerGUI
http://powergui.org/index.jspa
0
 
LVL 124
ID: 37037432
No requirement to butcher or use any other scripts on the Internet, just download the above, and you'll be running reports in minutes and not hours.
0
 

Author Comment

by:mikeleahy
ID: 37038960
i have installed powercli and im trying to download the power gui - site seems to be  down or something

when i run powercli i get an error Powercli environment.ps1 cannot be loaded because the execution of scripts is disabled on this sytem.  

I have run it on my vecenter server.
0
 

Author Comment

by:mikeleahy
ID: 37039006
sorry - i got it working . how can i find the mac addresses in use on my vcentre environment now
0
 
LVL 124
ID: 37039072
What have you downloaded, what I recommended?
0
 
LVL 124

Assisted Solution

by:Andrew Hancock (VMware vExpert / EE MVE^2)
Andrew Hancock (VMware vExpert / EE MVE^2) earned 1000 total points
ID: 37039107
If you have Download PowerCLI and PowerGUI.

1. Expand VMware folder
2. Expand Managed Hosts, and add a Managed Host e.g. vCenter server.
3. Connect to vCenter server using correct Userid and Password.
4. Expand Virtual Machines Folder
5. If all is well, it should display virtual machines
6. Select Virtual Machines
7. Click Network Adaptors in Right Hand Actions Column
8. It will display MAC Addresses
9. Select reporting options in Right Hand column
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 37039236
You can now paste the script from that link into powercli shell and let it run.
 
## Script function: find duplicate MAC addresses, and list the VMs/addresses involved
## Author: vNugglets.com

## get VirtualMachine .NET views where the items is not marked as a Template
$colDevMacAddrInfo = `
Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device -Filter @{"Config.Template" = "False"} | %{
   $strVMName = $_.Name
   $_.Config.Hardware.Device | Where-Object {$_ -is [VMware.Vim.VirtualEthernetCard]} | %{
       New-Object -Type PSObject -Property @{VMName = $strVMName; MacAddr = $_.MacAddress}
   } ## end foreach-object
} ## end foreach-object

## are all of the MAC addresses unique?
($colDevMacAddrInfo | Select-Object -unique MacAddr).Count -eq $colDevMacAddrInfo.Count

## get the non-unique MAC addresses, returning objects with the count of the duplicates, the duplicate MAC, and the VM names that have the duplicate MAC
$colDevMacAddrInfo | Group-Object MacAddr | Where-Object {$_.count -gt 1} | Select-Object Count,@{n="DuplicateMAC"; e={$_.Name}},@{n="VMNames"; e={($_.Group | %{$_.VMName}) -join ","}}

Open in new window

0
 

Author Comment

by:mikeleahy
ID: 37039349
i have tried to copy that script into the powercli and run and it throws loads of errors

with regard to the powerguui - i dont see any script to show vms by mac address???

0
 
LVL 124
ID: 37039552
follow my instructions above!
0
 

Author Comment

by:mikeleahy
ID: 37077645
I've requested that this question be deleted for the following reason:

no answer that helped me
0
 

Author Comment

by:mikeleahy
ID: 37077633
i did the close as a mistake

i want to assign points - please remove this so i can assign points
0
 
LVL 124
ID: 37077646
The PowerCLI and PowerGUI above shows how to display MAC addresses in a VMware Environment as shown in Post 37037423, Post 37039107 demonstrates how you generate the report.
0
 

Author Comment

by:mikeleahy
ID: 37077658
yes i know. read my recent post
0
 
LVL 124
ID: 37077668
cross posted at the moment I got the Delete Request.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
Teach the user how to edit .vmx files to add advanced configuration options Open vSphere Web Client: Edit Settings for a VM: Choose VM Options -> Advanced: Add Configuration Parameters:
Teach the user how to configure vSphere clusters to support the VMware FT feature Open vSphere Web Client: Verify vSphere HA is enabled: Verify netowrking for vMotion and FT Logging is in place or create it: Turn On FT for a virtual machine: Verify …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question