Geeks With Blogs

News

qrcode

Lance Robinson

Create Your Badge

Lance Robinson is a software engineer in Durham, Chapel Hill, Raleigh, and surrounding areas. More about Lance.

 Subscribe


Lance's TextBox » About Me » My Resume »Twitter

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.

Posted on Tuesday, May 5, 2009 5:42 PM PowerShell | Back to top


Comments on this post: PowerShellRSS Automatically Converts PSObjects to RSS Items

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Lance Robinson | Powered by: GeeksWithBlogs.net