Powershell–How do I find the Mac Addresses of my Server Network cards?

by Sean Kearney


Here’s a quick one.  A friend was working on a Hyper-V server and couldn’t find the MAC address of a network card.  “It’s not showing up under IPCONFIG as it’s not bound to TCP/IP”

Welcome to Powershell.   With Windows Powershell we can query the Win32_NetworkAdapter in WMI.

GET-WMIOBJECT Win32_NetworkAdapter

This would produce a list of ALL Network Adapters (Physical and Virtual) and their corresponding properties.

If you want, you can break that down to “All Physical Network Adapters” which should make your task easy.  

GET-WMIOBJECT –query ‘SELECT * from Win32_NetworkAdapter Where PhysicalAdapter=”TRUE”’

This however will still return some phantoms.   So we’ll filter this down to only Network Adapters which actually have a MacAddress

GET-WMIOBJECT –query ‘SELECT * from Win32_NetworkAdapter Where PhysicalAdapter=”TRUE” and MacAddress <>””’

Which gets an even SMALLER list.   But the Hyper-V virtual adapters still popup.   We can drill further down and get a more refined list by removing them.

GET-WMIOBJECT –query ‘SELECT * from Win32_NetworkAdapter Where PhysicalAdapter=”TRUE” and MacAddress <>”” and ServiceName <>”VMSMP”’

We can then take this output and sort it out by MacAddress and display it on screen in a more useful format.

GET-WMIOBJECT –query ‘SELECT * from Win32_NetworkAdapter Where PhysicalAdapter=”TRUE” and MacAddress <>”” and ServiceName <>”VMSMP”’ | SORT-OBJECT MacAddress | Format-Table

Life …. it’s always easier with a little Powershell Smile

One thought on “Powershell–How do I find the Mac Addresses of my Server Network cards?

  1. Pingback: Tipy pro Powershell – 2. díl | Igorovo

Leave a Reply