Last active
November 5, 2018 20:56
-
-
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/
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
$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