PowerShell/scripts/list-os-updates.ps1

39 lines
880 B
PowerShell
Raw Normal View History

2023-10-31 11:25:11 +01:00
<#
2021-07-13 21:10:02 +02:00
.SYNOPSIS
2023-04-12 14:02:15 +02:00
Lists OS updates
2021-10-04 21:29:23 +02:00
.DESCRIPTION
2023-04-12 14:02:15 +02:00
This PowerShell script lists the latest updates for operating systems.
2021-10-15 23:09:08 +02:00
.PARAMETER RSS_URL
Specifies the URL to the RSS feed
.PARAMETER MaxCount
Specifies the number of news to list
2021-07-13 21:10:02 +02:00
.EXAMPLE
2023-08-06 21:35:36 +02:00
PS> ./list-os-updates.ps1
2021-07-13 21:10:02 +02:00
.LINK
https://github.com/fleschutz/PowerShell
2022-01-29 12:47:46 +01:00
.NOTES
2022-09-06 21:42:04 +02:00
Author: Markus Fleschutz | License: CC0
2021-04-26 07:41:22 +02:00
#>
2023-04-12 14:02:15 +02:00
param([string]$RSS_URL = "https://distrowatch.com/news/dwd.xml", [int]$MaxCount = 30)
2021-04-26 07:41:22 +02:00
try {
2023-04-12 14:02:15 +02:00
" "
"Date OS Update"
"---- ---------"
[xml]$Content = (Invoke-WebRequest -URI $RSS_URL -userAgent "curl" -useBasicParsing).Content
2021-04-26 07:41:22 +02:00
[int]$Count = 0
foreach ($item in $Content.rss.channel.item) {
2023-04-12 14:02:15 +02:00
"$($item.title)"
2021-04-26 07:41:22 +02:00
$Count++
if ($Count -eq $MaxCount) { break }
}
2023-04-12 14:02:15 +02:00
" (source: DistroWatch.com)"
2021-09-27 10:09:45 +02:00
exit 0 # success
2021-04-26 07:41:22 +02:00
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2021-04-26 07:41:22 +02:00
exit 1
}