Skip to content

Instantly share code, notes, and snippets.

@mattmcnabb
Last active August 29, 2015 14:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mattmcnabb/5cac58a4c73492764829 to your computer and use it in GitHub Desktop.
2015-August Scripting Games Puzzle
# 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