PowerShell/docs/list-nina-warnings.md
2024-03-27 17:36:59 +01:00

70 lines
1.7 KiB
Markdown

Script: *list-nina-warnings.ps1*
========================
This PowerShell script queries the current NINA warnings and prints it.
Parameters
----------
```powershell
PS> ./list-nina-warnings.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
Example
-------
```powershell
PS> ./list-nina-warnings.ps1
```
Notes
-----
Author: Markus Fleschutz | License: CC0
Related Links
-------------
https://github.com/fleschutz/PowerShell
Script Content
--------------
```powershell
<#
.SYNOPSIS
Lists the current NINA warnings
.DESCRIPTION
This PowerShell script queries the current NINA warnings and prints it.
.EXAMPLE
PS> ./list-nina-warnings.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
Write-Progress "Loading NINA warnings..."
$warnings = (Invoke-WebRequest -URI https://warnung.bund.de/api31/dwd/mapData.json -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
Write-Progress -completed "Done."
Write-Output "Weather Warnings by DWD"
Write-Output "-----------------------"
foreach($warning in $warnings) {
$startDate = $warning.startDate
$expiresDate = $warning.expiresDate
$severity = $warning.severity
$urgency = $warning.urgency
$type = $warning.type
$message = $warning.i18nTitle.en
Write-Output "* $type from $startDate to $($expiresDate): $message ($severity, $urgency)"
}
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 03/27/2024 17:36:28)*