-
-
Save huoxudong125/a0a58dd8f4de59d386833afe735694c3 to your computer and use it in GitHub Desktop.
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
<# | |
.SYNOPSIS | |
Find MAC Address Vendors | |
.DESCRIPTION | |
Lookup Vendor of MAC Address regsitered on IEEE.org (Institute of Electrical and Electronics Engineers) database | |
.PARAMETER MACAddress | |
MAC address to lookup | |
.EXAMPLE | |
PS > Get-MACVendor -MACAddress "dc-4a-3e-81-d0-66","d4-81-d7-c4-34-43","48-4d-7e-e6-a8-94" | |
MACAddress ManufacturerName | |
---------- ---------------- | |
dc-4a-3e-81-d0-66 Hewlett Packard | |
d4-81-d7-c4-34-43 Dell Inc. | |
48-4d-7e-e6-a8-94 Dell Inc. | |
.EXAMPLE | |
PS > "18-DB-F2-48-51-F6","58-FB-84-C1-31-26","dc-4a-3e-81-d0-66","00-50-56-C0-00-01","00-50-56-C0-00-08" | Get-MACVendor | |
MACAddress ManufacturerName | |
---------- ---------------- | |
18-DB-F2-48-51-F6 Dell Inc. | |
58-FB-84-C1-31-26 Intel Corporate | |
dc-4a-3e-81-d0-66 Hewlett Packard | |
00-50-56-C0-00-01 VMware, Inc. | |
00-50-56-C0-00-08 VMware, Inc. | |
.NOTES | |
General notes | |
#> | |
Function Get-MACVendor { | |
Param( | |
[Parameter( | |
Mandatory = $true, | |
HelpMessage = 'MAC Address to lookup', | |
ValueFromPipeline = $true, | |
Position = 0 | |
)] | |
[ValidateNotNullOrEmpty()] | |
[string[]] $MACAddress | |
) | |
Begin{ | |
$TempFileName = "$env:TEMP\MACReference.csv" | |
If(Test-Path $TempFileName){ | |
$Data = Import-Csv $TempFileName | |
} | |
else{ | |
$Data = Invoke-WebRequest 'http://goo.gl/VG9XdU' | ` | |
ForEach-Object content | ` | |
Tee-Object -FilePath $TempFileName -Verbose | ConvertFrom-Csv | |
} | |
} | |
Process | |
{ | |
Foreach($MAC in $MACAddress){ | |
$Data.where({($MAC.replace(':','').replace('-','')[0..5] -join '') -in $_.assignment.split(' ')}) | ` | |
Select-Object @{n='MACAddress';e={$MAC}}, ManufacturerName -OutVariable Output | |
If(-not $Output) | |
{ | |
Write-Error "Couldn't find Manufacturer information for $MAC" | |
} | |
} | |
} | |
End{ | |
Remove-Variable -Name Data; [gc]::Collect() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment