MAC Address Lookups Using PowerShell and macvendors.com

I used to find it very tedious to lookup MAC addresses manually. I’d have a ton to work through so I had to find a way to automate the process.

Luckily, I found that my good ol’ friend PowerShell could be used in conjunction with a free API provided by macvendors.com. This allowed for MAC addresses to be saved into CSV files and worked through in batches.

I’ve noticed that this post is starting to gain more traffic, so I’ve decided to come back and rework it. Sorry if it’s changed a lot since you last checked it out! – 27th Dec 2024

Before we start, you can also read this article on Medium!

Introduction

If you haven’t seen or heard of macvendors.com before, it’s a super simple website that also exposes an API that allows for easy MAC address lookups. You can see the website below:

MAC address lookups - macvendors.com website

The task I was trying to automate was simple:

  1. Get a system (laptop/desktop) that was ready for destruction
  2. Search the MAC address online to find out the manufacturer info
  3. Add it to a list and document the system

Whilst I am simplifying this quite a bit, this is essentially what I had to do.



Rather than manually enter MAC addresses into the website, I saw that it also had a free API available. So I wondered if I could use the Invoke-WebRequest command from PowerShell to blast through my list of MAC addresses.

Lookup MAC Addresses

To perform a MAC address lookup using PowerShell and the macvendors.com API, it’s as simple as running this inside a PowerShell prompt:

$mac_example = "3C-07-71-75-BC-32" 
Invoke-WebRequest -Uri "https://api.macvendors.com/$mac_example"

From that request, I received the following information:

StatusCode        : 200
StatusDescription : OK
Content           : Sony Corporation
RawContent        : HTTP/1.1 200 OK
                    Connection: keep-alive
                    x-request-id: GBULs4JAkI7OtV0ATx5n
                    x-do-app-origin: c9cc0578-5d31-4bae-a690-bf01c1952665
                    x-do-orig-status: 200
                    CF-Cache-Status: MISS
                    CF-RAY: 8f89a7211a0b73...
Forms             : {}
Headers           : {[Connection, keep-alive], [x-request-id, GBULs4JAkI7OtV0ATx5n], [x-do-app-origin,
                    c9cc0578-5d31-4bae-a690-bf01c1952665], [x-do-orig-status, 200]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : System.__ComObject
RawContentLength  : 16

As you can see, this brings back a whole bunch of information that we don’t really want. All we’re interested in is the Content. Whilst you could use Piping to gather this info, the simplest for me is to wrap the request in brackets and return only the Content.

You can do this using:

(Invoke-WebRequest -Uri "https://api.macvendors.com/$mac_example").content

This now nicely returns only the data I’m interested in – “Sony Corporation

Sony Corporation

Enjoy! 🎉

Leave a Comment

Your email address will not be published. Required fields are marked *

email popup image
Mark Harwood
NEVER miss a blog post again! Subscribe for email notifications whenever a new post is live!
Subscribe
NEVER miss a blog post again! Subscribe for email notifications whenever a new post is live!
No obligation call, message, or email
Contact form image
I'll Be In Touch Soon