10 Replies Latest reply on Oct 29, 2010 4:24 PM by Matt.B

    Physical NIC MAC Address

    timrcase Lurker

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

        • 1. Re: Physical NIC MAC Address
          halr9000 Master

          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)

          • 2. Re: Physical NIC MAC Address
            sepso Enthusiast

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

            • 3. Re: Physical NIC MAC Address
              LucD Guru
              User ModeratorsCommunity WarriorsvExpert

              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 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: Physical NIC MAC Address
                I_C Enthusiast

                great stuff!!!

                • 5. Re: Physical NIC MAC Address
                  jkyoutsey Enthusiast
                  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})}

                  • 6. Re: Physical NIC MAC Address
                    ngerasim Enthusiast

                    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

                    • 7. Re: Physical NIC MAC Address
                      LucD Guru
                      User ModeratorsCommunity WarriorsvExpert

                      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 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      • 8. Re: Physical NIC MAC Address
                        ngerasim Enthusiast

                        PowerCLI Version

                        -


                        VMware vSphere PowerCLI 4.0 U1 build 208462

                        • 9. Re: Physical NIC MAC Address
                          Matt.B Enthusiast

                          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.

                          • 10. Re: Physical NIC MAC Address
                            LucD Guru
                            vExpertUser ModeratorsCommunity Warriors

                            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 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz