Download Podcasts with PowerShell

A while back, I saw this article from the Scripting Guy on parsing RSS feeds.
Being an avid RSS feeds consumer and podcast watcher/listener, this was a “aha” moment.
After all, podcasts are basically RSS feeds with a media file attached to each entry. So, my project was to build PowerShell cmdlets to extract the desired information from podcasts and podcast entries/episodes, and to download them.

The first version of my Podcast module was using Invoke-WebRequest for the download of media files. It was quite slow and if there was multiple media files to download, it was not downloading them in parallel.

So, this new version uses BITS to download the media files via the cmdlet Start-BitsTransfer. This has many advantages :

  • It is faster
  • It allows to start several downloads in parallel using the parameter -Asynchronous
  • It pauses the download(s) if connectivity is lost and automatically resumes them when the connectivity is back.
  • It allows to easily track the progress of download(s) with the property
    BytesTransferred of the BitsJob object(s).

I won’t explain the code in the whole module because it would take at least 4 blog articles alone. I will just demonstrate the usage of its 4 cmdlets.

Get-Podcast :

You can give it one or more podcast URL(s) to obtain information on the most recent episodes for the specified podcasts :


It is also possible to send it a bunch of URLs via the pipeline.

Most often, I don’t manually specify URLs, I give it a file listing all my favorite podcasts as input :


Notice the parameter -FromLastDays, this retrieves only the podcasts published after the specified number of days ago. This is a nice way to check your podcasts for updates. Here, I know I was up-to-date on all my favorite podcasts 7 days ago so I use -FromLastDays to check what is new since then.

By the way, if you want a list of cool tech podcasts, here is mine :

Save-Podcast :

It takes the same parameters as Get-Podcast with the additional -Destination which allows to specify where the media file is saved.


The nice part is that you can pipe the output of Get-Podcast to Save-Podcast. So, you can check the output of Get-Podcast first, without committing to download and then, if you actually want to download the output podcast episodes, you can add | Save-Podcast to your previous command :


One limitation when you do it this way : Save-Podcast is getting one media file at a time through the pipeline, so the downloads are sequential, not in parallel. This also means that the count of files and the total size displayed by Write-Progress are incorrect. The count of files is always 1 when using pipeline input. If you have a solution for this, I am all hears.

Add-PodcastToList :

This allows to add podcast URLs to the file containing your favorite podcasts, without having to manually edit the file. It can also create a list of podcasts because if the file specified doesn’t exist, it creates it :

PS C:\> Add-PodcastToList -Url -List $env:USERPROFILE\Desktop


You can also use this cmdlet in combination with Get-Podcast to create a new podcast list from an existing list :

PS C:\> Get-Podcast -List C:\GitHub\Powershell-Utility\Podcast\PodcastList.txt -FromLastDays 30 |
 Where-Object { $_.Summary -like "*scripting*" } |
 Add-PodcastToList -List $env:USERPROFILE\Desktop\ScriptingPodcasts.txt

As you can see above, I got podcasts from my main podcast list selecting only the episodes from the last 30 days because I don’t need a huge number of episodes. Then, I filter down to the episodes which have the word “scripting” in their Summary field and I add the PodcastUrl from these episodes to a new list.

Don’t worry if multiple episodes of the same podcast match the filter, Add-PodcastToList will not add the same URL more than once, because it checks if the destination list already contains the URL before adding it.

Remove-PodcastFromList :

This cmdlet allows to remove podcast URLs from a podcast list, without having to manually edit the file :

PS C:\> Remove-PodcastFromList "" "$env:USERPROFILE\Desktop\FavoritePodcasts.txt"

Here, we were using positional parameters, -Url is at position 0 and -List is at position 1.

Podcasts can come and go, or some podcasts can be a series on a specific topic and are not updated after the series is finished. You can use Remove-PodcastFromList to cleanup stale podcasts from a list, like so :

PS C:\> Get-Podcast "C:\GitHub\Powershell-Utility\Podcast\PodcastList.txt" -Last 1 |
 Where-Object { $_.PublishedDate -lt (Get-Date).AddMonths(-6) } |
 Remove-PodcastFromList -List "C:\GitHub\Powershell-Utility\Podcast\PodcastList.txt"

This obtains the last episode of each podcast in the list, then it filters down to the episodes older than 6 months ago. We assume that if the latest episode is older than 6 months, the podcast is probably finished or abandoned, so we remove it from the list.

That’s pretty much all there is to using the Podcast module. It is available for grabbing and/or improving on this GitHub repository.

Leave a Reply

Your email address will not be published. Required fields are marked *