# encoding: ascii
# api: powershell
# title: LookUp-WirelessLocation
# description: This simple function translates a wireless AP’s BBID (mac) through the SkyhookWireless API’s to return location information…
# version: 2.6
# type: function
# author: CrazyDave
# license: CC0
# function: LookUp-Location
# x-poshcode-id: 643
# x-archived: 2016-05-23T02:55:57
# x-published: 2009-10-19T05:08:00
#
# Currently the output is just the raw XML response from the server…
#
function LookUp-Location {
param([String] $mac)
$mac = $mac.Replace(":","").Replace("-","")

$wClient = New-Object System.Net.WebClient
$body = "<?xml version='1.0'?><LocationRQ xmlns='http://skyhookwireless.com/wps/2005' version='2.6' street-address-lookup='full'><authentication version='2.0'><simple><username>beta</username><realm>js.loki.com</realm></simple></authentication><access-point><mac>#{mac}</mac><signal-strength>-50</signal-strength></access-point></LocationRQ>"
$url = "https://api.skyhookwireless.com/wps2/location"
$wClient.Headers.Add("Content-Type:text/xml")
$body = $body.Replace("#{mac}", $mac)

$response = $wClient.UploadString($url, $body)
return $response
}
