mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-17 14:00:55 +02: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
|
.PARAMETER Location
|
||||||
Specifies the location to use (determined automatically per default)
|
Specifies the location to use (determined automatically per default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./ping-weather Paris
|
PS> ./ping-weather
|
||||||
Sunny 🌡23°C ☂️0.0mm 💨9km/h from S ☁️0% 💧41% ☀️UV6 1020hPa 🕗10:24 AM UTC @Paris (Ile-de-France)...
|
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
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$Location = "", [int]$UpdateInterval = 600000)
|
param([string]$Location = "", [int]$UpdateInterval = 600)
|
||||||
|
|
||||||
try {
|
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 {
|
do {
|
||||||
$Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
|
||||||
$Description = $Weather.current_condition.WeatherDesc.value
|
$Description = $Weather.current_condition.WeatherDesc.value
|
||||||
$TempC = $Weather.current_condition.temp_C
|
$TempC = $Weather.current_condition.temp_C
|
||||||
$PrecipMM = $Weather.current_condition.precipMM
|
$PrecipMM = $Weather.current_condition.precipMM
|
||||||
@ -30,10 +35,10 @@ try {
|
|||||||
$Visib = $Weather.current_condition.visibility
|
$Visib = $Weather.current_condition.visibility
|
||||||
$Pressure = $Weather.current_condition.pressure
|
$Pressure = $Weather.current_condition.pressure
|
||||||
$Time = $Weather.current_condition.observation_time
|
$Time = $Weather.current_condition.observation_time
|
||||||
$Area = $Weather.nearest_area.areaName.value
|
|
||||||
$Region = $Weather.nearest_area.region.value
|
"🕗$Time UTC 🌡$($TempC)°C ☂️$($PrecipMM)mm 💨$($WindSpeed)km/h from $WindDir ☁️$($Clouds)% 💧$($Humidity)% ☀️UV$UV 👀$($Visib)km $($Pressure)hPa $Description"
|
||||||
"$Description 🌡$($TempC)°C ☂️$($PrecipMM)mm 💨$($WindSpeed)km/h from $WindDir ☁️$($Clouds)% 💧$($Humidity)% ☀️UV$UV 👀$($Visib)km $($Pressure)hPa 🕗$Time UTC @$Area ($Region)..."
|
Start-Sleep -s $UpdateInterval
|
||||||
start-sleep -milliseconds $UpdateInterval
|
$Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
||||||
} while ($true)
|
} while ($true)
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user