Skip to content

Instantly share code, notes, and snippets.

@csandfeld
Last active October 4, 2015 21:35
Show Gist options
  • Save csandfeld/e5a7ea4eb149ec859701 to your computer and use it in GitHub Desktop.
Save csandfeld/e5a7ea4eb149ec859701 to your computer and use it in GitHub Desktop.
@csandfeld 2015 - October Scripting Games Puzzle
function Get-RSSFeed {
[CmdletBinding()]
Param(
[Parameter(
Mandatory = $True
)]
[String[]]
$Uri
)
BEGIN {
$Items = @()
$Select = @{
#'Property' = @('title', @{ l = 'Date' ; e = { Get-Date $_.pubDate } } )
'Property' = @(
@{ l = 'Channel' ; e = { $_.channel.title } },
'title',
'pubDate',
'Date'
)
}
}
PROCESS {
foreach ($feed in $Uri) {
$xml = [xml](Invoke-WebRequest -Uri $feed).Content
$FeedName = $xml.rss.channel.title
foreach ($Item in $xml.rss.channel.item) {
$Properties = [Ordered]@{
'Feed' = $FeedName
'FeedUri' = $feed
'Title' = $Item.title
'Date' = (Get-Date -Date $Item.pubDate)
'Link' = $Item.link
}
$Items += New-Object -TypeName PSObject -Property $Properties
}
}
$Items | Sort-Object -Property Date -Descending
}
}
Get-RSSFeed -Uri http://powershell.org/wp/feed/, http://blogs.technet.com/b/heyscriptingguy/rss.aspx | fl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment