Last active
November 8, 2021 00:14
-
-
Save David54236/86a56863c4b62cba442d8c11d43aad97 to your computer and use it in GitHub Desktop.
Gets the vendor for macAddress from "api.macvendors.com"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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