Get MAC Address from IP Address

I got a call last week from a member of one the other teams where I work.  He asked, “Do you have a script which will resolve a list of IP Addresses to MAC Addresses?” My answer was, “not yet”.  I did a search and found some very convoluted Pinvoke code. I wanted something easier.

When I automate a task, I begin with the manual steps for the task. To get a MAC address from an IP address, I ping the address, then look at the ARP cache. Get-MACFromIP.ps1 does the same thing,  using the inline script method to make the process run in parallel for speed.  It does not require any administrative rights to run, and is an advanced function.  A use example follows, others are in the code help:

I the use WMI ping method to enable name resolution and the return codes.  The script outputs the IP address, DNS Name (if it can be resolved), MAC address, and the verbose level ping reply.  Capture of the output of the ARP table is based on this post, by Joe Keohan.

Script Text

Tags: , ,

Leave a Reply

You must be logged in to post a comment.