Reading RSS Feeds–Even easier in PowerShell V3

by Doug Finke on September 22, 2011

PowerShell V3 introduces Invoke-RestMethod, the CTP can be  found here. This simplifies working with XML returned from the Web, like RSS feeds.

Compare V3 to V2 below. V3 uses 50% fewer lines of code.

PowerShell V3

$url = "http://blogs.msdn.com/b/powershell/rss.aspx"            
Invoke-RestMethod $url | Select Title, Link

PowerShell V2

$url = "http://blogs.msdn.com/b/powershell/rss.aspx"            
            
$wc = New-Object net.webclient            
[xml]$xml = $wc.DownloadString($url)            
$xml.rss.channel.item | Select Title, Link

The results are the same

# Results            
            
title                                                                            link                                                                           
-----                                                                            ----                                                                           
Cmdlet Help Editor is now released on CodePlex                                   http://blogs.msdn.com/b/powershell/archive/2011/09/21/cmdlet-help-editor-is-...
Windows Management Framework 3.0 Community Technology Preview (CTP) #1 Availa... http://blogs.msdn.com/b/powershell/archive/2011/09/20/windows-management-fra...
8 Abstracts for the PowerShell Deep Dive in Frankfurt                            http://blogs.msdn.com/b/powershell/archive/2011/09/01/8-abstracts-for-the-po...
Get-Help -Online Fails in German                                                 http://blogs.msdn.com/b/powershell/archive/2011/08/23/get-help-online-fails-...
Extending Discounted Registration & Session Proposal Deadline                    http://blogs.msdn.com/b/powershell/archive/2011/08/02/extending-discounted-r...
PowerShell Deep Dive Registration Info & Call for Session Proposals              http://blogs.msdn.com/b/powershell/archive/2011/07/20/powershell-deep-dive-r...
PowerShell Deep Dive @ The Experts Conference Europe 2011                        http://blogs.msdn.com/b/powershell/archive/2011/07/12/powershell-deep-dive-t...
Invoke-Expression considered harmful                                             http://blogs.msdn.com/b/powershell/archive/2011/06/03/invoke-expression-cons...
Download the Updated Core Help CHM                                               http://blogs.msdn.com/b/powershell/archive/2011/05/17/download-the-updated-c...
PowerShell at TechEd 2011                                                        http://blogs.msdn.com/b/powershell/archive/2011/04/28/powershell-at-teched-2...
Keeping Help Helpful: Use -Online and Redirectable Links                         http://blogs.msdn.com/b/powershell/archive/2011/04/22/keeping-help-helpful-u...
PowerShell Language now licensed under the Community Promise                     http://blogs.msdn.com/b/powershell/archive/2011/04/16/powershell-language-no...
Using Get-WinEvent –FilterXml to process Windows Events                        http://blogs.msdn.com/b/powershell/archive/2011/04/14/using-get-winevent-fil...
Scaling and Queuing PowerShell Background Jobs                                   http://blogs.msdn.com/b/powershell/archive/2011/04/04/scaling-and-queuing-po...
Only 2 days left to save $1000 on PowerShell Deep Dive registration              http://blogs.msdn.com/b/powershell/archive/2011/03/30/only-2-days-left-to-sa...
More Deep Dive Info, Including Abstracts from the PowerShell Team                http://blogs.msdn.com/b/powershell/archive/2011/03/13/more-deep-dive-info-in...
Four more reasons to come to the PowerShell Deep Dive                            http://blogs.msdn.com/b/powershell/archive/2011/03/08/four-more-reasons-to-c...
A Few Deep Dive Abstracts                                                        http://blogs.msdn.com/b/powershell/archive/2011/03/05/a-few-deep-dive-abstra...
Cmdlet Help Editor V2.0 with Module Support                                      http://blogs.msdn.com/b/powershell/archive/2011/02/24/cmdlet-help-editor-v2-...
Reminder: Register for the PowerShell Deep Dive Conference & submit your sess... http://blogs.msdn.com/b/powershell/archive/2011/02/23/reminder-register-for-...
Does Your Hard Work Advance the Ecosystem?                                       http://blogs.msdn.com/b/powershell/archive/2011/02/07/does-your-hard-work-ad...
PowerShell Deep Dive Conference                                                  http://blogs.msdn.com/b/powershell/archive/2011/02/04/powershell-deep-dive-c...
Looking for your Feedback                                                        http://blogs.msdn.com/b/powershell/archive/2011/01/18/looking-for-your-feedb...
A very touching final goodbye                                                    http://blogs.msdn.com/b/powershell/archive/2011/01/13/a-very-touching-final-...
Same Command. Different Return Types.                                            http://blogs.msdn.com/b/powershell/archive/2010/12/10/same-command-different...

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>