Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

MAC Address Vendor Lookup

$
0
0

Hi,

I put together the below in around 5 minutes as a helper function for another project I thought it may be useful for someone else, enjoy.

Function Invoke-MACVendorLookup { [CmdletBinding( HelpUri = 'https://macvendors.com/api' )] [OutputType([String])] param( [Parameter( Mandatory = $true, HelpMessage = 'MAC Address to lookup', ValueFromPipeline = $true, Position = 0 )] [string]$MACAddress ) Begin { Write-Verbose -Message 'Adding System.Web Assembly' Add-Type -AssemblyName System.Web } Process { $WebRequest = New-Object -TypeName system.Net.WebClient $MACAddress = [Web.HttpUtility]::UrlEncode($MACAddress) Write-Verbose -Message 'Getting results' try { $Result = $WebRequest.downloadString("http://api.macvendors.com/$MACAddress") } catch { Write-Error -Message 'Unable to lookup MAC Address' break } } End { Write-Output -InputObject $Result } } 

submitted by /u/nightshade2109
[link] [comments]

The post MAC Address Vendor Lookup appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles