VMware Cloud Community
timrcase
Contributor
Contributor
Jump to solution

Physical NIC MAC Address

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

Reply
0 Kudos
1 Solution

Accepted Solutions
halr9000
Commander
Commander
Jump to solution

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

View solution in original post

Reply
0 Kudos
10 Replies
halr9000
Commander
Commander
Jump to solution

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
Reply
0 Kudos
sepso
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
I_C
Enthusiast
Enthusiast
Jump to solution

great stuff!!!

Reply
0 Kudos
jkyoutsey
Contributor
Contributor
Jump to solution

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})}

Reply
0 Kudos
ngerasim
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ngerasim
Contributor
Contributor
Jump to solution

PowerCLI Version

-


VMware vSphere PowerCLI 4.0 U1 build 208462

Reply
0 Kudos
Matt_B1
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos