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