Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PowersShell BingMapsLatLongFromAddress
function Get-BingMapsLatLongFromAddress
param (
[String] $AddressLine,
[String] $CountryCode,
[String] $AdminState,
[String] $AdminCity
$BingMapsKey = 'Your_Key_Goes_Here'
$URI = ""+$CountryCode+"/"+$AdminState+"/"+$AdminCity+"/"+$AddressLine+"?inclnb=1&MaxResults=1&key=$BingMapsKey"
$WebData = Invoke-WebRequest -Method Get -Uri $URI -UseBasicParsing
$WebDataContentObject = $WebData.Content | ConvertFrom-Json
$Coords = $WebDataContentObject.resourceSets.resources.point.coordinates
$CoordinateObject = [PSCustomObject]@{
Latitude = $Coords[0]
Longitude = $Coords[1]
return $CoordinateObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.