First listed source code is without authentication, whereas the second is with basic authentication
param (
[Parameter( Mandatory=$true)]
[string]$Address
)
clear
function Get-MAC() {
param($Address)
begin {
$APIURL = "http://<URL>/address.xml?&search="
$resource = "$($APIURL)$($Address)"
$mac = Invoke-RestMethod -URI $resource -Method Get
$hash = @{
Status_Code = $mac.Response.Status_Code
Company_Name = $mac.Response.Company_Name
MAC_Address = $mac.Response.MAC_Address
}
$result = New-Object PSObject -Property $hash | Format-Table Company_Name -AutoSize
return $result
}
}
Get-MAC($Address)
param (
[Parameter( Mandatory=$true)]
[string]$Address
)
clear
function Get-MAC() {
param($Address)
begin {
$APIURL = "http://<URL>/address.xml?&search="
$resource = "$($APIURL)$($Address)"
$username="Username"
$password="Password"
$mac = Invoke-RestMethod -URI $resource -Headers @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username+":"+$password ))} -Method Get
$hash = @{
Status_Code = $mac.Response.Status_Code
Company_Name = $mac.Response.Company_Name
MAC_Address = $mac.Response.MAC_Address
}
$result = New-Object PSObject -Property $hash | Format-Table Company_Name -AutoSize
return $result
}
}
Get-MAC($Address)
GitHub: https://gist.github.com/dkittell/65890843f6224e45bb4e
Originally Posted on December 22, 2015
Last Updated on February 12, 2016
Last Updated on February 12, 2016
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.