Last active
January 28, 2018 07:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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