Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get MAC Address via powershell

I have a large number of devices (servers and workstations) that I need to gather network adapter MAC’s and the associated IP’s for. I have a working script but for some reason, it does not return the MAC in the results. Am I doing something wrong or am I not using the correct verbiage?

Get-NetIPConfiguration -ComputerName ComputerName -Detailed | select ComputerName,macaddressipv4address

When I run the Get-NetIPConfiguration without the pipe, it does return a MAC address value. But when I add in the select pipe, it only returns the computer name and IP address. The MAC column is blank.

Any ideas?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

MacAddress is a nested property in the NetAdapter property, you can use a calculated property to get it:

Get-NetIPConfiguration -ComputerName ComputerName -Detailed |
    Select-Object ComputerName, @{ N='MacAddress'; E={ $_.NetAdapter.MacAddress }}, @{ N='IPv4Address'; E={ $_.IPv4Address.IPAddress }}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading