diff --git a/Data/scripts.csv b/Data/scripts.csv index c1646a38..b4539636 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -81,6 +81,7 @@ list-formatted.ps1, lists the current working directory formatted in columns list-fritzbox-calls.ps1, lists the FRITZ!Box calls list-fritzbox-devices.ps1, lists FRITZ!Box's known devices list-hidden-files.ps1, lists hidden files within the given directory tree +list-hourly-weather.ps1, lists the hourly weather today list-installed-apps.ps1, lists the installed Windows Store apps list-installed-software.ps1, lists the installed software (except Windows Store apps) list-logbook.ps1, lists the content of the logbook diff --git a/README.md b/README.md index c06539a8..8b280eb9 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,7 @@ Mega Collection of PowerShell Scripts * [list-environment-variables.ps1](Scripts/list-environment-variables.ps1) - lists all environment variables * [list-fritzbox-calls.ps1](Scripts/list-fritzbox-calls.ps1) - lists the FRITZ!Box calls * [list-fritzbox-devices.ps1](Scripts/list-fritzbox-devices.ps1) - lists FRITZ!Box's known devices +* [list-hourly-weather.ps1](Scripts/list-hourly-weather.ps1) - lists the hourly weather today * [list-logbook.ps1](Scripts/list-logbook.ps1) - lists the content of the logbook * [list-earthquakes.ps1](Scripts/list-earthquakes.ps1) - lists earthquakes with magnitude >= 6.0 for the last 30 days * [list-mysql-tables.ps1](Scripts/list-mysql-tables.ps1) - lists the MySQL server tables diff --git a/Scripts/list-hourly-weather.ps1 b/Scripts/list-hourly-weather.ps1 new file mode 100755 index 00000000..4d61a71c --- /dev/null +++ b/Scripts/list-hourly-weather.ps1 @@ -0,0 +1,39 @@ +#!/usr/bin/pwsh +<# +.SYNTAX list-hourly-weather.ps1 [] +.DESCRIPTION lists the hourly weather today +.LINK https://github.com/fleschutz/PowerShell +.NOTES Author: Markus Fleschutz / License: CC0 +#> + +param($Location = "") # empty means determine automatically + +try { + $Weather = (Invoke-WebRequest http://wttr.in/${Location}?format=j1 -UserAgent "curl" ).Content | ConvertFrom-Json + + $Area = $Weather.nearest_area.areaName.value + $Region = $Weather.nearest_area.region.value + $Country = $Weather.nearest_area.country.value + "Hourly weather today at $Area, $Region ($Country)" + + [int]$Hour = 0 + foreach ($Hourly in $Weather.weather.hourly) { + $Temp = $Hourly.tempC + $Precip = $Hourly.precipMM + $Humidity = $Hourly.humidity + $Pressure = $Hourly.pressure + $WindSpeed = $Hourly.windspeedKmph + $WindDir = $Hourly.winddir16Point + $UV = $Hourly.uvIndex + $Visib = $Hourly.visibility + $Clouds = $Hourly.cloudcover + $Desc = $Hourly.weatherDesc.value + "$($Hour):00: $($Temp)°C $($Precip)mm $($Humidity)% $($Pressure)hPa $WindDir $($WindSpeed)km/h UV$($UV) $($Visib)km $($Clouds)% ($Desc)" + $Hour++ + } + + exit 0 +} catch { + write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}