Get-Geocode

Function Get-Geocode { [CmdletBinding()] Param ( [Parameter(Mandatory=$True)] [String]$Address, [ValidateSet("xml", "json")] [String]$Output = "xml", [String]$Region = "", [String]$Language = "", [String]$Proxy ) Begin { $webClient = New-Object System.Net.WebClient $url = "http://maps.googleapis.com/maps/api/geocode/$($Output.ToLower())?address=" $sensor = "&sensor=false" if ($Region -ne "") { $Region = "&region=$Region" } if ($Language -ne "") { $Language = "&language=$Language" } if ($Proxy) { Write-Debug []

Geocoding with PowerShell

Version 3 of Google’s Geocoding API does not return information in CSV format. This updated code processes the XML returned by the new API. Function Add-Geocode { param( [Parameter(ValueFromPipeline=$True)] [PSObject]$InputObject ) Begin { $webClient = New-Object System.Net.WebClient $pre = "http://maps.googleapis.com/maps/api/geocode/xml?address=" $suf = "&sensor=false" } Process { $queryString = @( $pre $InputObject.address $InputObject.city $InputObject.state $InputObject.zip $suf) []

Geocoding with PowerShell and Google Geocoding API V2

This function uses the Google Maps Geocoding API Version 2. It accepts objects with address, city, state and zip parameters. It then uses that information to find the longitude and latitude of the location and adds additional properties to the object. I use it with Import-CSV and Export-CSV to add information to a spreadsheet. Function []