Get-MacManufacturer.ps1


<#PSScriptInfo
 
.VERSION 1.0.1
 
.GUID 2f98442d-f65b-44d7-8194-7e1812fbd3af
 
.AUTHOR Dave Long <dlong@cagedata.com>
 
.COMPANYNAME Cage Data, Inc.
 
.COPYRIGHT (c) 2020 David Long. All rights reserved.
 
.TAGS Networking
 
.LICENSEURI https://raw.githubusercontent.com/davejlong/PSAtera/master/LICENSE
 
.DESCRIPTION
  Get the manufacturer of MAC addresses.
 
#>

<#
.SYNOPSIS
  Get the manufacturer of MAC addresses.
 
.PARAMETER MACAddress
  MAC Address to get manufacturer of. Can be formatted with hyphens (-) of colons (:)
 
.PARAMETER IPAddress
  IP Address on the local network to query. Uses ARP to determine MAC address.
 
.EXAMPLE Get device manufacturer
  PS> Get-MacManufacturer -MACAddress "04-18-D6-06-9D-EA"
 
  Ubiquiti Networks Inc.
 
.EXAMPLE Get manufacturer of device by IP address
  PS> Get-MacManufacturer -IPAddress 192.168.1.5
 
  Intel Corporate
 
.EXAMPLE Get Manufacturer of local Wi-Fi adapter
  PS> Get-NetAdapter "Wi-Fi" | Get-MacManufacturer
 
  Intel Corporate
#>

[CmdletBinding(DefaultParameterSetName="byMac")]
Param(
  [Parameter(Mandatory=$true, Position=0, ParameterSetName="byMac", ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
  [string] $MACAddress,
  [Parameter(ParameterSetName="byIP")]
  [string] $IPAddress
)

if ($IPAddress) {
  $MACAddress = (Get-NetNeighbor -IPAddress $IPAddress).LinkLayerAddress
}

Invoke-RestMethod "https://api.macvendors.com/$($MACAddress)"