Geeks With Blogs

Lance's TextBox

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' "";
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";


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: