Skip navigation
VMware

This Question is Answered (go to answer)

2 "helpful" answers available (6 pts)
1,772 Views 10 Replies Last post: Oct 29, 2010 4:24 PM by Matt.B RSS
timrcase Lurker 2 posts since
Sep 8, 2008
Currently Being Moderated

Sep 10, 2008 2:38 PM

Physical NIC MAC Address

Can you get the MAC address for your physical NICs using the PowerShell toolkit?

halr9000 Master vExpert 1,124 posts since
Jun 7, 2007
Currently Being Moderated
1. Sep 10, 2008 4:27 PM in response to: timrcase
Re: Physical NIC MAC Address

Yes, it's buried deep inside of the object returned by Get-VMHostNetwork.

 

PS > Get-VMHost | Get-VMHostNetwork | select -expandProperty PhysicalNic | format-list *


BitRatePerSec      : 100
FullDuplex         : True
WakeOnLanSupported : True
Id                 : key-vim.host.PhysicalNic-vmnic0
DeviceName         : vmnic0
Mac                : 00:c0:9f:3a:64:6a
DhcpEnabled        : False
IP                 :
SubnetMask         :

BitRatePerSec      : 100
FullDuplex         : True
WakeOnLanSupported : True
Id                 : key-vim.host.PhysicalNic-vmnic0
DeviceName         : vmnic0
Mac                : 00:c0:9f:3a:56:04
DhcpEnabled        : False
IP                 :
SubnetMask         :

 






Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
sysengvmw Novice VMware Employees 11 posts since
Jul 3, 2008
Currently Being Moderated
2. Oct 6, 2008 11:47 AM in response to: halr9000
Re: Physical NIC MAC Address

How about the flipside - Can I identify a VM if I only have the MAC address?

LucD Guru User Moderators vExpert 8,981 posts since
Oct 31, 2005
Currently Being Moderated
3. Oct 6, 2008 2:04 PM in response to: sysengvmw
Re: Physical NIC MAC Address

Something like this should do the trick.

$tgtMAC = "00:50:56:b3:30:38"
$vms = Get-VM
foreach($vm in $vms){
  $vmMAC = $vm | Get-NetworkAdapter | select MacAddress
  foreach($mac in $vmMAC){
    if($mac.MacAddress -eq $tgtMAC) {
       Write-Host $vm.Name
     }
  }
}

 

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
I_C Enthusiast 52 posts since
Jun 3, 2008
Currently Being Moderated
4. Oct 6, 2008 2:33 PM in response to: LucD
Re: Physical NIC MAC Address

great stuff!!!

jkyoutsey Enthusiast 30 posts since
Dec 10, 2008
Currently Being Moderated
5. Aug 7, 2009 9:00 AM in response to: halr9000
Re: Physical NIC MAC Address
halr9000 wrote:

PS > Get-VMHost | Get-VMHostNetwork | select -expandProperty PhysicalNic | format-list *

 

I have two hosts and each has two NICs.  I get the following error:

Get-VMHostNetwork : Index was outside the bounds of the array.
At line:1 char:31
+ Get-VMHost | Get-VMHostNetwork <<<<  | select -expandProperty PhysicalNic | f
ormat-list *
    + CategoryInfo          : NotSpecified: (:) [Get-VMHostNetwork], IndexOutO
   fRangeException
    + FullyQualifiedErrorId : System.IndexOutOfRangeException,VMware.VimAutoma
   tion.Commands.Host.GetVmHostNetwork

 

I'm really after getting this information in a decent Xml format that relates the host name to the individual NICs.  I've also tried this but it doesn't end up with a relationship between the host and the NICs.

Get-vmHost | %{Get-View $_.id} | %{$_.name $($_.config.network.pnic | %{$_.device, $_.mac})}

ngerasim Enthusiast 86 posts since
Mar 15, 2010
Currently Being Moderated
6. Jun 8, 2010 10:43 AM in response to: timrcase
Re: Physical NIC MAC Address

I used this follows script, however the results are not as they should be. I do not see a MAC address specified.

 

Get-VMHost | Get-VMHostNetwork | select -expandProperty PhysicalNic | format-list *

 

BitRatePerSec      : 1000

FullDuplex         : True

WakeOnLanSupported : False

Id                 : key-vim.host.PhysicalNic-vmnic0

VMHostId           : HostSystem-host-5509

DeviceName         : vmnic0

Mac                :

DhcpEnabled        : False

IP                 :

SubnetMask         :

Name               : vmnic0

 

BitRatePerSec      : 1000

FullDuplex         : True

WakeOnLanSupported : False

Id                 : key-vim.host.PhysicalNic-vmnic3

VMHostId           : HostSystem-host-5509

DeviceName         : vmnic3

Mac                :

DhcpEnabled        : False

IP                 :

SubnetMask         :

Name               : vmnic3

 

BitRatePerSec      : 1000

FullDuplex         : True

WakeOnLanSupported : False

Id                 : key-vim.host.PhysicalNic-vmnic4

VMHostId           : HostSystem-host-5509

DeviceName         : vmnic4

Mac                :

DhcpEnabled        : False

IP                 :

SubnetMask         :

Name               : vmnic4

 

BitRatePerSec      : 1000

FullDuplex         : True

WakeOnLanSupported : False

Id                 : key-vim.host.PhysicalNic-vmnic5

VMHostId           : HostSystem-host-5509

DeviceName         : vmnic5

Mac                :

DhcpEnabled        : False

IP                 :

SubnetMask         :

Name               : vmnic5

 

BitRatePerSec      : 1000

FullDuplex         : True

WakeOnLanSupported : False

Id                 : key-vim.host.PhysicalNic-vmnic0

VMHostId           : HostSystem-host-9640

DeviceName         : vmnic0

Mac                :

DhcpEnabled        : False

IP                 :

SubnetMask         :

Name               : vmnic0

LucD Guru User Moderators vExpert 8,981 posts since
Oct 31, 2005
Currently Being Moderated
7. Jun 8, 2010 11:25 AM in response to: ngerasim
Re: Physical NIC MAC Address

Strange, the MAC property should be in there.

 

Which PowerCLI version are you running ?

Can you do a


Get-PowerCLIVersion

 

 

 

 

____________

Blog: LucD notes

Twitter: lucd22

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com
ngerasim Enthusiast 86 posts since
Mar 15, 2010
Currently Being Moderated
8. Jun 8, 2010 5:07 PM in response to: LucD
Re: Physical NIC MAC Address

PowerCLI Version

-


VMware vSphere PowerCLI 4.0 U1 build 208462

Matt.B Enthusiast 98 posts since
Aug 7, 2008
Currently Being Moderated
9. Oct 29, 2010 4:24 PM in response to: LucD
Re: Physical NIC MAC Address

To search by MAC or IP, does it require VMware tools to be installed and running to report out that information?  We have some Linux hosts without VMware tools so I am curious to know if they will not be included when searching for an IP.

LucD Guru User Moderators vExpert 8,981 posts since
Oct 31, 2005
Currently Being Moderated
10. Oct 29, 2010 5:33 PM in response to: Matt.B
Re: Physical NIC MAC Address

The MAC can be found without the Tools installed, for the IP addr the Tools need to be installed.

 

 

 

 

____________

Blog: LucD notes

Twitter: lucd22

Blog: http://lucd.info | Twitter: @LucD22 | Book co-author: http://powerclibook.com

Bookmarked By (0)

Share This Page

Communities