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