Add max-count to list-news.ps1

This commit is contained in:
Markus Fleschutz 2021-04-22 10:13:58 +02:00
parent 6406e4360b
commit c58b33b7d8

View File

@ -1,11 +1,11 @@
<# <#
.SYNTAX list-news.ps1 [<RSS-URL>] .SYNTAX list-news.ps1 [<RSS-URL>] [<max-count>]
.DESCRIPTION lists the latest news .DESCRIPTION lists the latest news
.LINK https://github.com/fleschutz/PowerShell .LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0 .NOTES Author: Markus Fleschutz / License: CC0
#> #>
param($RSS_URL = "https://yahoo.com/news/rss/world") param($RSS_URL = "https://yahoo.com/news/rss/world", [int]$MaxCount = 20)
try { try {
[xml]$Content = (invoke-webRequest -URI $RSS_URL).Content [xml]$Content = (invoke-webRequest -URI $RSS_URL).Content
@ -15,7 +15,7 @@ try {
foreach ($item in $Content.rss.channel.item) { foreach ($item in $Content.rss.channel.item) {
"$($item.title)" "$($item.title)"
$Count++ $Count++
if ($Count -eq 26) { break } if ($Count -eq $MaxCount) { break }
} }
exit 0 exit 0
} catch { } catch {