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

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

About Sean Kearney

"Living the Dream at Microsoft!" A long time ago in a Shell far far away a little guy had a dream, to work at Microsoft. For many years that dream lay by the wayside until his career encountered PowerShell, a technology so cool and easy to use, it made him sing. (Search for Highway to PowerShell and you'll see how badly ;) ) Once encountering PowerShell his career jumped from being a field technician, to working for a Fortune 15 Healthcare corporation, to working for a Microsoft BlackBelt Partner in Ottawa and working with Ed Wilson for many years on the Scripting Blog ... to his dream, handed down from the lands of Microsoft on the day his Dad passed on. A gift from beyond. So to those of you that think dreams don't happen. Think again. PowerShell changed this little person and it will change you too.

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

Comments are closed.