2015-August Scripting Games Puzzle
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
# A one-liner to return the desired output | |
Invoke-RestMethod -Uri 'telize.com/geoip' | Select-Object longitude, latitude, continent_code, timezone | |
# Wrapped with a function - simple but works | |
Function Get-GeoInformation | |
{ | |
[CmdletBinding()] | |
Param | |
( | |
[System.Net.IPAddress] | |
$IPAddress | |
) | |
$Uri = 'telize.com/geoip' | |
if($IPAddress) { $Uri += "/$IPAddress" } | |
Invoke-RestMethod -Method Get -Uri $Uri | |
} | |
# Never format output in a function! Once you have formatted your output you can do no further manipulation of the output because you aren't returning the original objects. | |
# Here's a great website with a searchable directory of web apis. | |
# http://www.programmableweb.com/apis/directory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment