Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Last active November 5, 2018 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjrobinson/0436e640175a29ef8a278277677858ae to your computer and use it in GitHub Desktop.
Save darrenjrobinson/0436e640175a29ef8a278277677858ae to your computer and use it in GitHub Desktop.
Azure Trigger PowerShell Function to lookup Vendor/Manufacturer. Associated Blog Post can be found here https://blog.darrenjrobinson.com/an-azure-powershell-trigger-function-for-mac-address-vendor-manufacturer-lookup/
$requestBody = Get-Content $req -Raw | ConvertFrom-Json
$query = $requestBody.query
$query
if ($query)
{
# LOAD MAC Address to Vendors PSObjects
$vendors = Import-Clixml -Path "D:\home\site\wwwroot\YOURAZUREFUNCTION\Vendors.xml"
$output = $null
$response = $null
if ($query.Contains("-")) {
$response = $vendors | Select-Object | Where-Object {$_.hex -eq $query}
if ($response){
$output = (Get-Culture).textinfo.totitlecase($response.vendor.tolower())
}
}
else {
$response = $vendors | Select-Object | Where-Object {$_.base16 -eq $query}
if ($response){
$output = (Get-Culture).textinfo.totitlecase($response.vendor.tolower())
}
}
}
if ($output) {
$output
Out-File -Encoding ASCII -FilePath $res -inputObject $output
} else {
$output = "MACAddress Vendor not found"
$output
Out-File -Encoding ASCII -FilePath $res -inputObject $output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment