Skip to content

Instantly share code, notes, and snippets.

@David54236
Last active November 8, 2021 00:14
Show Gist options
  • Save David54236/86a56863c4b62cba442d8c11d43aad97 to your computer and use it in GitHub Desktop.
Save David54236/86a56863c4b62cba442d8c11d43aad97 to your computer and use it in GitHub Desktop.
Gets the vendor for macAddress from "api.macvendors.com"
Function Get-VendorFromMacAddress
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $macAddress
)
Begin
{
Write-Verbose -Message ('Starting {0} with {1} parameterset' -f $MyInvocation.InvocationName, $PsCmdlet.ParameterSetName)
}
Process
{
try
{
$vendor = (Invoke-WebRequest -UseBasicParsing -Uri ("https://api.macvendors.com/" + $macAddress)).Content
}
catch
{
$vendor = 'UNKNOWN VENDOR'
}
return $vendor
}
End
{
Write-Verbose -Message ('Ending {0}' -f $MyInvocation.InvocationName)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment