Skip to content

Instantly share code, notes, and snippets.

@Agazoth
Last active January 28, 2018 07:27
Show Gist options
  • Save Agazoth/37a4c6272218e64704b80ce934cf707d to your computer and use it in GitHub Desktop.
Save Agazoth/37a4c6272218e64704b80ce934cf707d to your computer and use it in GitHub Desktop.
Gets a newsfeed and lets the user select a specific feed to display in either browser or console
function Get-Feed {
[CmdletBinding()]
param ($Feeduri = 'https://powershell.org/feed/')
$c = 0
$Feeds = Invoke-RestMethod -uri $Feeduri
$FeedObjects = foreach ($Feed in $Feeds){
[PSCustomObject]@{
'No.' = ++$c
Title = $Feed.title
"Publication date" = $Feed.pubDate
Link = $Feed.link
Author = $Feed.creator.'#cdata-section'
}
}
$FeedObjects | Format-Table -AutoSize
while ($FeedObjects.'No.' -notcontains $FeedChoice){$FeedChoice = Read-Host -Prompt 'Select the feed No. you want to read'}
$FeedObject = $FeedObjects | Where-Object {$_.'No.' -eq $FeedChoice}
while ($EndpointChoice -notmatch '^(B|C)$') {$EndpointChoice = Read-Host "Display $($Feed.title) in [B]rowser or [C]onsole?"}
if ($EndpointChoice -eq 'B'){
Start-Process $FeedObject.Link
} else {
Invoke-RestMethod $FeedObject.Link
}
}
iex $(irm https://gist.githubusercontent.com/Agazoth/37a4c6272218e64704b80ce934cf707d/raw/1c8cff6d081dd74a94da1c4045b9481379f27363/Get-Feed.ps1);get-feed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment