The Kill Lock an Amazing comic
The Kill Lock an Amazing comic

# Get-MacAddressVendor 🖥️

By
,
Powershell
,
Modules
Published 2022-07-19

Module Located Here
https://www.powershellgallery.com/packages/Get-MacAddressVendor/1.0

# Just saying ☀️

me enjoying the sun yesterday
me enjoying the sun yesterday

At the moment in the U.K 🇬🇧 it is hot 🌞 like really super hot 🥵 and I guess we are just not used to it. Hence pretty much no-where has air-con so we all just melt, or maybe that's just our air-ports ✈️ yep that really did happen yesterday. Despite all this heat, I managed to cook up a module and a Github repository and this web-page all before starting work 🏋️ just for fun 🥳 and to hopefully demonstrate how awesome this Retype module is for documenting your work.

# Links to Module 👇

So as mentioned this is on the Powershell gallery:-

Powershell Gallery Link 👉
https://www.powershellgallery.com/packages/Get-MacAddressVendor/1.0

I also published a quick repository on Github as well:-

My Github Repository 👉
https://github.com/psDevUK/Get-MacAddressVendor

Don't forget there is also this amazing website 😁

This Website 👉
https://www.adam-bacon.netlify.app

# Why Do this module? 💭

Well the other day at work someone from a different team showed a member in the team I work in a MAC address. The colleague I work with automatically said that this was vendor name MAC address. This other person didn't believe him, so the colleague I work with went to some website to verify it really was the vendor name he said it was. So late last night a bit before going to bed I was thinking about this conversation again, and thought yeah I know I could probably obtain this information via WMI or CIM or point and click device manager. However I thought this would be a great opportunity to show how to do this via an API, so I wrote the function last night just before going to bed. I also had a quick butchers on the Powershell Gallery and well I personally couldn't find anything like this on the Powershell Gallery. Maybe it's something that does not get talked about a lot in other offices? Anyways upon shutting down my laptop, I just thought lets make it a mission tomorrow morning (today) to write a quick blog, make a repository and publish to the Powershell Gallery to hopefully inspire other coders out there that you can do all of this before you even start work 😄 if you so wish 🔮

# Code 💬

Sadly there really isn't much code behind this module, it's a magic Powershell one-liner that does all the hardwork

<#
.Synopsis
   Finds the vendor from a given MAC Address
.DESCRIPTION
   Uses the api.macvendors.com to find the vendor of the supplied MAC Address so you will require internet connection for this function to run smoothly
.EXAMPLE
   Get-MacAddressVendor -MacAddress E0-9D-31-18-B5-7C
.EXAMPLE 
   "E0-9D-31-18-B5-7C" | Get-MacAddressVendor
#>
function Get-MacAddressVendor
{
    [CmdletBinding()]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                  ValueFromPipeline=$true,
                   Position=0)]
         [ValidatePattern('^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$')]
        $MacAddress
    )

    Begin
    {
 
    }
    Process
    {
Foreach ($Address in $MacAddress){
   try
   {
       Write-Host -ForegroundColor Yellow "Processing $Address to find the vendor"
       Invoke-WebRequest -UseBasicParsing -Uri "https://api.macvendors.com/$Address" -Method GET | select -ExpandProperty Content -ErrorAction Stop
   }
   catch 
   {
       $bad = $_
       Write-Warning "Crumbs something went wrong $bad"  
   }
}      
    }
    End
    {
    }
}

Thanks for reading, hope you enjoyed
Thanks for reading, hope you enjoyed