PowerShell, Atlanta Techstravaganza, and reading the PowerScripting.net RSS Feed with PowerShell

Today I had the pleasure of co-presenting “What’s new in Windows 8 PowerShell” (aka PowerShell v3) with my friend, Microsoft Regional Developer Evangelist Glen Gordon (blog | twitter).

You can find the slide deck for our presentation here.

We had a lot of code demos in the presentation, and some due to the short time period we didn’t get to. I’ll be posting the demos over the next few weeks, doing it slowly so as not to overwhelm anyone.

Below is the code to pull the RSS feed for the PowerScripting podcast. The code is pretty self explanatory, see the comments for more info.

#region Reading RSS Feeds

  #----------------------------------------------------------------------------
  # Reading RSS Feeds
  #----------------------------------------------------------------------------
  
    # Reading RSS Feeds has become even easier in v3
    $url = "http://feeds.feedburner.com/Powerscripting?format=xml"
  
    # v2 Syntax
    $webClient = New-Object net.webclient
    [xml]$rss = $webClient.DownloadString($url)
    $rss.rss.channel.item |
       Select-Object Title, pubDate, duration  |
       Format-List 
  
    # v3 Syntax
    Invoke-RestMethod $url |
       Select-Object Title, pubDate, duration  |
       Format-List 

    # To know the available object names, open the RSS
    # feed and look at the XML tags inside. The ones
    # shown in this example are pretty commong to most feeds.
  
#endregion Reading RSS Feeds
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: