Last active
August 29, 2015 14:26
-
-
Save ady28/b63b779aa4aa0e14603d to your computer and use it in GitHub Desktop.
This file contains 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
#One liner in which I use Invoke-Restmethod and select only the 4 properties keeping the output as an object for other operations | |
Invoke-RestMethod -Uri "www.telize.com/geoip" | Select-Object -Property longitude,latitude,continent_code,timezone | |
#Advanced function that just calls the above CmdLet | |
Function GetGeoInformation | |
{ | |
Invoke-RestMethod -Uri "www.telize.com/geoip" | |
} | |
#Use the dvanced function by placing the results in a variable | |
$geoinfo=GetGeoInformation | Select-Object -Property longitude,latitude,continent_code,timezone | |
<# | |
Another interesting service that has an XML endpoint is found at http://openweathermap.org/current. This site give you information about weather. | |
This page has infomation about using the service. I chose to use the longitude and latitude to retreive the weather data. | |
The url is: api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon} | |
The bove function can be used for this: | |
#> | |
$geoinfo=GetGeoInformation | |
Invoke-RestMethod -Uri "api.openweathermap.org/data/2.5/weather?lat=$($geoinfo.latitude)&lon=$($geoinfo.longitude)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment