How to get Weather Conditions with PowerShell

      Comments Off on How to get Weather Conditions with PowerShell

powershell_liteI try some online tricks with PowerShell, yes is true is POWER this shell.
I used the Yahoo Weather API


I get my weather on Cluj-Napoca with get the forecast info, GEO infos and the current conditions. Let’ s see how:

[code lang=”powershell”]
#get the RSS
$feed=[xml](new-object system.net.webclient).downloadstring(“http://weather.yahooapis.com/forecastrss?p=ROXX0022&u=c”)
$long = $feed.rss.channel.Item.long
$lat = $feed.rss.channel.Item.lat
$current_cond_text = $feed.rss.channel.Item.condition.text
$current_cond_temp = $feed.rss.channel.Item.condition.temp
$current_cond_date = $feed.rss.channel.Item.condition.date

#write out the infos
$feed.rss.channel.Item.title
Write-Output “::GPS info [latitude/longitude] : $lat $long”
Write-Output “::Current contitions: $current_cond_text with $current_cond_temp C at $current_cond_date ”

Write-Output “`n ::Forecast”
$feed.rss.channel.Item.forecast

[/code]