Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
# # This section pulls the json data from WU. Collecting it as straight # text as the OP doesn't get all the data, so it has to be converted to JSON # $UrlWU = "https://api.weather.com/v2/pws/observations/current?stationId={stationID}&format=json&units=e&apiKey={apikey}" $CurrentWeather = Invoke-RestMethod "$UrlWU" $CurrentWeather | ConvertTo-Json -depth 100 # # This section pulls the condition down from wttr.in, # check https://github.com/chubin/wttr.in/blob/master/README.md for codes # $CurrentWeatherWttr = Invoke-RestMethod "https://wttr.in/{ZIP/Lat-Lon/Place-Name}?format=%C" # # This section is crafting the string that gets written to the text file. It pulls the object values from the WU response blob in JSON. # Going straight Out-File wasn't working, so I did a Write-Output to form the string, then do the Out-File on that. # $json = Write-Output "Cond: $($CurrentWeatherWttr) | Temp: $($CurrentWeather.observations.imperial.temp)°F | Wind Speed: $($CurrentWeather.observations.imperial.windSpeed)MPH @ $($CurrentWeather.observations.winddir)°" $json | Out-File -FilePath "C:\BlueIris\weather.txt" -Encoding UTF8 # # Now Bob's your uncle.