Created
May 6, 2016 15:52
-
-
Save 1RedOne/8f6d64b53f21bb695bde57124f368e43 to your computer and use it in GitHub Desktop.
Get-Weather
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
Function Get-Weather { | |
$city = "33.9533,-84.5406" | |
#sign up for an API key here https://developer.forecast.io/ | |
$APIkey = "$null" | |
$url = "https://api.forecast.io/forecast/$APIkey/$city" | |
try{$weather = Invoke-WebRequest $url -ea STOP|ConvertFrom-Json } | |
catch{write-host -ForegroundColor Yellow "We don't seem to have internet access" | |
break} | |
$ForeCastTime = [TimeZone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($weather.currently.time)) | |
("The weather is generally " + $weather.currently.summary + " and currently " + $weather.currently.temperature + " degrees Fahrenheit at " + $ForeCastTime.DateTime) | |
("wind is gusting up to " + $weather.currently.windspeed + " m/PH with a chance of precipitation at " + $weather.currently.precipProbability) | |
#it is currently 54.9 degrees Fahrenheit at Monday, October 20, 2014 10:23:11 AM | |
("The weekly forecast is " + (($weather.daily.summary) -creplace '\?',"").ToLower()) | |
#return a Global weather object for us to play with | |
$Global:weather = $weather | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment