Creating Colorful Weather Report

In the previous tip we explained how you can retrieve weather forecast data using Invoke-WebRequest. This was pure black-and-white text.

To get a colorful report, on Windows 10 you can take advantage of control sequences supported by powershell.exe. Simply run the code below inside a PowerShell console:

$City = 'Hannover'

(Invoke-WebRequest "http://wttr.in/$City" -UserAgent curl).content -split "`n"

By setting the user agent to “curl”, the output includes the color control sequences which in turn are picked up by Windows 10 powershell.exe.

Twitter This Tip! ReTweet this Tip!