-
-
Save jerkovicl/afb1f60b400bc7fa67044f47822fb19f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function Get-LongLat | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipelineByPropertyName = $true | |
)] | |
[string[]]$ZipCode | |
) | |
process | |
{ | |
foreach($z in $ZipCode) | |
{ | |
Write-Verbose "Getting geometry for $z" | |
$data = Invoke-RestMethod -Method Get -Uri "http://maps.googleapis.com/maps/api/geocode/json?address=$z" | |
$obj = [pscustomobject]@{ | |
ZipCode = $z | |
Address = $data.results.formatted_address | |
Latitude = $data.results.geometry.location.lat | |
Longitude = $data.results.geometry.location.lng | |
} | |
Write-Output $obj | |
} | |
} | |
} | |
function Get-Forecast | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipelineByPropertyName = $true | |
)] | |
[string]$Latitude, | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipelineByPropertyName = $true | |
)] | |
[string]$Longitude, | |
[Parameter( | |
Mandatory = $false, | |
ValueFromPipelineByPropertyName = $true | |
)] | |
[string]$Apikey = 'myapikeyhere' | |
) | |
process | |
{ | |
Write-Verbose "Getting forecast for $Latitude,$Longitude" | |
$data = Invoke-RestMethod -Method Get -Uri "https://api.forecast.io/forecast/$ApiKey/$Latitude,$Longitude" | |
Write-Output $data | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment