Public/Get-PowerShellNews.ps1
function Get-PowerShellNews { <# .SYNOPSIS Zeigt offizielle News zum Thema PowerShell von Microsoft. .EXAMPLE Get-PowerShellNews Zeigt offizielle News zum Thema PowerShell von Microsoft. .OUTPUTS [System.String] #> [CmdletBinding()] param( [datetime]$AfterDate = [datetime]::MinValue ) begin { $My = [HashTable]::Synchronized(@{}) $My.ESC = [char]0x1b $My.FormatHeader = "$($My.ESC)[95m" $My.FormatReleaseLogo = "📅 " $My.FormatTitle = "📯 $($My.ESC)[36m" $My.FormatDefault = "$($My.ESC)[0m" if (!$host.UI.SupportsVirtualTerminal) { $My.FormatHeader = [String]::Empty $My.FormatReleaseLogo = [String]::Empty $My.FormatTitle = [String]::Empty $My.FormatDefault = [String]::Empty } "$($My.FormatHeader) $($My.FormatDefault)" | Out-Host "$($My.FormatHeader)Microsoft PowerShell Blog $($My.FormatReleaseLogo)News (https://devblogs.microsoft.com/powershell):$($My.FormatDefault)" | Out-Host try { $My.Content = [xml](Invoke-WebRequest -Uri 'https://devblogs.microsoft.com/powershell/feed/' -ErrorAction Stop | Select-Object -ExpandProperty Content) } catch { "Vermutlich ist das Internet aktuelle nicht zu erreichen. Daher können keine News abgerufen werden." | Write-Warning exit } $My.Content.rss.channel.Item | Select-Object -Property @{Name='ReleaseDate'; Expression={ [DateTime]$_.pubDate } }, title, link | Where-Object -Property ReleaseDate -GE -Value $AfterDate | ForEach-Object -Process { return [PSCustomObject]@{ Release = "$($My.FormatReleaseLogo){0:yyyy-MM-dd}" -f $_.ReleaseDate News = $My.FormatTitle + "`e]8;;$($_.link)`e\$($_.Title)`e]8;;`e\" + $My.FormatDefault } } } end { Remove-Variable -Name My -Force -ErrorAction Ignore } } |