2024-01-25 13:37:12 +01:00
|
|
|
Script: *list-nina-warnings.ps1*
|
|
|
|
========================
|
2023-12-07 20:24:45 +01:00
|
|
|
|
2024-05-19 10:25:56 +02:00
|
|
|
list-nina-warnings.ps1
|
|
|
|
|
2023-12-07 20:24:45 +01:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
```powershell
|
2024-05-19 10:25:56 +02:00
|
|
|
|
2023-12-07 20:24:45 +01:00
|
|
|
|
|
|
|
[<CommonParameters>]
|
|
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
|
|
```
|
|
|
|
|
|
|
|
Script Content
|
|
|
|
--------------
|
|
|
|
```powershell
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
2024-05-19 10:25:56 +02:00
|
|
|
Lists the current weather warnings by NINA
|
2023-12-07 20:24:45 +01:00
|
|
|
.DESCRIPTION
|
2024-05-19 10:25:56 +02:00
|
|
|
This PowerShell script queries the current NINA weather warnings and lists it.
|
2023-12-07 20:24:45 +01:00
|
|
|
.EXAMPLE
|
|
|
|
PS> ./list-nina-warnings.ps1
|
|
|
|
.LINK
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
#>
|
|
|
|
|
2024-05-19 10:25:56 +02:00
|
|
|
function ListWarningsOf([string]$category, [string]$source)
|
|
|
|
{
|
2023-12-07 20:24:45 +01:00
|
|
|
Write-Progress "Loading NINA warnings..."
|
2024-05-19 10:25:56 +02:00
|
|
|
$warnings = (Invoke-WebRequest -URI https://warnung.bund.de/api31/$category/mapData.json -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
2023-12-07 20:24:45 +01:00
|
|
|
Write-Progress -completed "Done."
|
2024-05-19 10:25:56 +02:00
|
|
|
|
2023-12-07 20:24:45 +01:00
|
|
|
foreach($warning in $warnings) {
|
2024-05-19 10:25:56 +02:00
|
|
|
$message = $warning.i18nTitle.en
|
2023-12-07 20:24:45 +01:00
|
|
|
$startDate = $warning.startDate
|
|
|
|
$expiresDate = $warning.expiresDate
|
|
|
|
$severity = $warning.severity
|
|
|
|
$urgency = $warning.urgency
|
|
|
|
$type = $warning.type
|
2024-05-19 10:25:56 +02:00
|
|
|
Write-Output "* $message"
|
|
|
|
Write-Output " from $startDate to $expiresDate ($source $type, $severity, $urgency)"
|
|
|
|
Write-Output ""
|
2023-12-07 20:24:45 +01:00
|
|
|
}
|
2024-05-19 10:25:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Write-Output ""
|
|
|
|
ListWarningsOf "katwarn" "Katwarn"
|
|
|
|
ListWarningsOf "dwd" "DWD"
|
|
|
|
ListWarningsOf "police" "Police"
|
|
|
|
ListWarningsOf "lhp" "LHP"
|
|
|
|
ListWarningsOf "biwapp" "Biwapp"
|
2023-12-07 20:24:45 +01:00
|
|
|
exit 0 # success
|
|
|
|
} catch {
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-19 10:25:56 +02:00
|
|
|
*(generated by convert-ps2md.ps1 using the comment-based help of list-nina-warnings.ps1 as of 05/19/2024 10:25:22)*
|