PowerShellRSS Automatically Converts PSObjects to RSS Items

In a previous post, I talked about how PowerShellASP can be used to generate an RSS feed with PowerShell.  Now I’ll show how the same feed can be generated more easily with PowerShellRSS.

Again, the dir command in PowerShell (get-childitem) is used to get a listing of files to use as enclosures in the feed.

# This example demonstrates how to generate an RSS feed from a call to the Get-ChildItem cmdlet (dir). # To tailor to your specific needs, set the following values: $mediadir = 'C:\Testing\media';
$virtualdirectory = 'media';

# Check for user input $dir = $request['path']
if ( $dir -eq $null ) {
$dir = $mediadir;
}

#Set the feed title and other basic feed attributes set-feedattr 'rss:title' "PowerShellASP Get-RSS Sample";
set-feedattr 'rss:link' "http://www.powershelltoys.com";
set-feedattr 'rss:description' "This example uses PowerShellASP to generate an RSS feed using PowerShell cmdlets.";

ls $dir | %{
@{
'rss:updated' = $_.LastWriteTime.ToString('R');
'rss:title' = "Podcast episode: $($_.Name)";
'rss:enclosure@url' = "http://" + $request.servervariables["SERVER_NAME"] + ":" + $request.servervariables["SERVER_PORT"] + "/$virtualdirectory/" + $_.Name;
'rss:enclosure@length' = $_.Length;
'rss:enclosure@type' = "audio/mp3";
}
}

Simple.

Print | posted on Tuesday, May 05, 2009 5:42 PM

Feedback

No comments posted yet.

Your comment:





 
 

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski