Friday Fun Quote of the Day

For this week’s Friday Fun post, I have another idea on how to brighten your PowerShell console. The concept of a message of the day or quote of the day in computing goes way back to the dark ages (ie before PowerShell). I thought it might be fun to see what we could do with this idea. Continue reading

PowerShell Weather Module

I first wrote a Windows PowerShell function several years ago to retrieve weather information via Yahoo’s weather service. I’ve been itching to rewrite it and finally found some time over the weekend. Turns out it’s a good thing I did because the method I had been using to query the Yahoo web service has been deprecated. My original version relied on a zip or postal code. But now Yahoo relies on a WOEID or “Where on Earth ID”.

The underlying structure of my Get-Weather function hasn’t changed much. Using the Webclient object I query the Yahoo web service, retrieve an XML document and parse it. I then write a custom object to the pipeline.
[cc lang=”DOS”]
PS C:\> get-weather 12762649

Date              : Mon, 26 Jul 2010 7:54 am EDT
Location          : Jamesville, NY
Temperature       : 67 F
Condition         : Partly Cloudy
ForecastCondition : Sunny
ForecastLow       : 60 F
ForecastHigh      : 80 F
My new version includes a lot more information.  The function’s default is this basic view. However you can also specify Extended or All. I defined a set or properties and then pipe my custom object to Select-Object specifying the appropriate property set.

Since the new version requires a WOEID, you’re probably wondering how to find it. One way is to go to and enter in your zip code or location in the search box. Your WOEID will be the number at the end of the url that is returned. Or you can use the Get-Woied function. This function takes some sort of search and returns a simple object, including the WOEID.
[cc lang=”DOS”]
PS C:\> get-woeid “Detroit,MI”

Country : US
Region  : Michigan
Postal  :
Locale  : Detroit
WOEID   : 2391585

PS C:\> get-woeid 68132

Country : US
Region  : Nebraska
Postal  : 68132
Locale  : Omaha
WOEID   : 12787550

You can even use the two in a pipeline.
[cc lang=”DOS”]
PS C:\> get-woeid 68132 | get-weather -extended

Date              : Mon, 26 Jul 2010 6:52 am CDT
Location          : Omaha, NE
Temperature       : 70 F
Condition         : Partly Cloudy
ForecastCondition : Partly Cloudy
ForecastLow       : 72 F
ForecastHigh      : 88 F
WindChill         : 70 F
WindSpeed         : 5 mph
Humidity          : 84%
Barometer         : 30.07 in and steady
Visibility        : 10  mi
Tomorrow          : Tue 27 Jul 2010 Mostly Sunny Low 74F: High: 94F
I’ve put everything together in a module, JH-Weather. The module also defines aliases of gwid and gw for Get-Woeid and Get-Weather, respectively. I have some other ideas for the module so stay tuned for future releases. In the mean time you can download a zip file with the module here.