Speak the weather

Script Sharing

So, I am working on creating a Good Morning script to help wake myself up since im a heavy sleeper and I want to. This is the first part ive worked on, it will go get the weather, parse the xml, and read it to me.

If interested, or you want to mess around with the XML, you can find your US cities XML here

http://pastebin.com/J4hCR8k0

Posted Feb 21, 2017, 6:33 PM UTC · edited

156
jpochedl•

I am curious why you saved the XML file first, then reloaded the file instead of using the results of invoke-webrequest directly...? (I'm near Cleveland...)

[XML]$weatherCLEHopkins = Invoke-WebRequest -uri 'http://w1.weather.gov/xml/current_obs/KCLE.xml'
$weatherCLEHopkins.current_observation.temp_f
65.0
6
emceetate•

I'd prefer to see some error handling that exclaims "Wake up! I'm broken"

4
0fsysadminworkOP•

Not sure if I will or not, since I copy the xml locally, if the next web request fails, it will fall back to yesterdays report. I could call the updated time from the XML and compare it to the current date and make a separate message to alert me to this.

I messed with it last night when i got home, but my bluetooth soundbar is a bit too far from my computer, so I might move that and test some more.

2
emceetate•

I had no idea System.Speech was a thing, so thanks for this. I'm probably going to spend too much time making my co-workers' computers talk

4
0fsysadminworkOP•

That is what I originally used the function for :P

Here's where I stole it from. http://mattblogsit.com/oob/powershell-pranks-making-work-fun-with-creepy-voices

3
0fsysadminworkOP•

Honestly, I just followed an example on a blog post or site and edited for my use. I assumed that it was better to work with a local copy instead of directly from the web.

Now that you point it out, that is probably fine. The site rarely goes down and either does my internet.

1