Getting Network Adapter information using PowerCLI

So recently I was asked for a list of MAC addresses for all the VMs in my demo environment… Didn’t really want to do this manually by going into each VM and checking the hardware settings, so thought I’d see if I can find some PowerCLI commands that will do the job…… After a short dive into the PowerCLI reference guide I found the following commands worked:

Get-VM |
Get-NetworkAdapter |
Select-Object -property Parent, MacAddress
Format-List -Property *

mac

Note: I’m assuming you know how to use the vSphere PowerCLI Interface….. if not, you’ll need to connect to the vCenter Server in PowerCLI before running the cmdlets above!

If you don’t use the Select-Object command, it will list every property field for each of the network adapters, as I only wanted the VM name and MAC address, those were the properties that I chose.

You can even output the info to a txt file by adding the > c:\xxx.txt after the Select-Object command line, or even output to a csx file (using | Export-csv c:\xxx.csv)

Advertisements

One comment on “Getting Network Adapter information using PowerCLI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s