mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-21 23:43:25 +01:00
Update ping-weather.ps1
This commit is contained in:
parent
b5349dc5ae
commit
d83e8e7bda
@ -1,15 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Opens the AccuWeather website
|
||||
.DESCRIPTION
|
||||
This PowerShell script launches the Web browser with the AccuWeather website.
|
||||
.EXAMPLE
|
||||
PS> ./open-accu-weather
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
& "$PSScriptRoot/open-default-browser.ps1" "https://www.accuweather.com"
|
||||
exit 0 # success
|
@ -1,20 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Launches the Microsoft Weather app
|
||||
.DESCRIPTION
|
||||
This script launches the Microsoft Weather application.
|
||||
.EXAMPLE
|
||||
PS> ./open-microsoft-weather
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
Start-Process msnweather:
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Opens the Space Weather website
|
||||
.DESCRIPTION
|
||||
This script launches the Web browser with the Space Weather website.
|
||||
.EXAMPLE
|
||||
PS> ./open-space-weather
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
& "$PSScriptRoot/open-default-browser.ps1" "https://www.spaceweather.com"
|
||||
exit 0 # success
|
@ -6,19 +6,24 @@
|
||||
.PARAMETER Location
|
||||
Specifies the location to use (determined automatically per default)
|
||||
.EXAMPLE
|
||||
PS> ./ping-weather Paris
|
||||
Sunny 🌡23°C ☂️0.0mm 💨9km/h from S ☁️0% 💧41% ☀️UV6 1020hPa 🕗10:24 AM UTC @Paris (Ile-de-France)...
|
||||
PS> ./ping-weather
|
||||
Current weather conditions at Paris (Ile-de-France), updating every 10 min...
|
||||
🕗10:24 AM UTC 🌡23°C ☂️0.0mm 💨9km/h from S ☁️0% 💧41% ☀️UV6 1020hPa Sunny
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$Location = "", [int]$UpdateInterval = 600000)
|
||||
param([string]$Location = "", [int]$UpdateInterval = 600)
|
||||
|
||||
try {
|
||||
$Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
||||
$Area = $Weather.nearest_area.areaName.value
|
||||
$Region = $Weather.nearest_area.region.value
|
||||
"Current weather conditions at $Area ($Region), updating every $($UpdateInterval / 60) min..."
|
||||
do {
|
||||
$Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
||||
|
||||
$Description = $Weather.current_condition.WeatherDesc.value
|
||||
$TempC = $Weather.current_condition.temp_C
|
||||
$PrecipMM = $Weather.current_condition.precipMM
|
||||
@ -30,10 +35,10 @@ try {
|
||||
$Visib = $Weather.current_condition.visibility
|
||||
$Pressure = $Weather.current_condition.pressure
|
||||
$Time = $Weather.current_condition.observation_time
|
||||
$Area = $Weather.nearest_area.areaName.value
|
||||
$Region = $Weather.nearest_area.region.value
|
||||
"$Description 🌡$($TempC)°C ☂️$($PrecipMM)mm 💨$($WindSpeed)km/h from $WindDir ☁️$($Clouds)% 💧$($Humidity)% ☀️UV$UV 👀$($Visib)km $($Pressure)hPa 🕗$Time UTC @$Area ($Region)..."
|
||||
start-sleep -milliseconds $UpdateInterval
|
||||
|
||||
"🕗$Time UTC 🌡$($TempC)°C ☂️$($PrecipMM)mm 💨$($WindSpeed)km/h from $WindDir ☁️$($Clouds)% 💧$($Humidity)% ☀️UV$UV 👀$($Visib)km $($Pressure)hPa $Description"
|
||||
Start-Sleep -s $UpdateInterval
|
||||
$Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
||||
} while ($true)
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user