On Windows PowerShell and other admin-related topics

Download TechNet Edge videos using Windows PowerShell

I recently got a question on Twitter if I could create a PowerShell script to download files from TechNet Edge. I thought this would be useful for many other people as well, so I have spent some time this weekend working on this script. I wanted to make the script as generic and re-usable as possible, so even though I started hardcoding it for downloading files from a given RSS-feed from TechNet Edge, I later on generalized it to make it easy to re-use on other websites  as well. The script is called Get-WebVideoFile.ps1, and is available on both PoshCode and the Microsoft TechNet Script Center.

How to use the script

1) The script requires PowerShell 2.0 and you must have configured your PowerShell execution policy in order to run the script. Run $host.version from PowerShell to see what version you are running. If you need help configuring the execution policy or running the script, see “Running Windows PowerShell Scripts” on Microsoft TechNet.

2) Download the script from here (PoshCode) or here (Microsoft TechNet Script Center).

3) Find the RSS URL for the category you want to download files from. On TechNet Edge you can find an overview of all categories (called tags) on this link.


In this example I have chosen the Microsoft Virtual Academy tag:


You can then find the RSS URL by clicking on the RSS icon to the right of the title on the top of the page.

4) Specify the URL on the RssUrl parameter when running the Get-WebVideoFile script:


You will get a progress bar which shows the progress for the current file:


Remember that you can also use Windows PowerShell ISE (or any 3rd party host) instead of the PowerShell console host:


More information about the script

Comment based help

At the top of the script you can see that I have added comment based help. This means you can use Get-Help to show information and example usage of the script:



You can read more about comment based help in this TechNet Magazine Article by Don Jones, as well as in the help topic about_Comment_Based_Help.


RssUrl – This is the only mandatory parameter, which provides the script the RSS feed to go through. The script download the HTML code from each RSS entry`s link, and look for a URL that matches the regular expression.

Destination – The folder the files will be downloaded to. If not specified the files will be downloaded to the current user`s Video-folder (for example C:\Users\Username\Videos\).

UseOriginalFileName – This is a switch parameter to specify that you want to use the original file names for the downloaded files. On TechNet Edge most video files got a non-descriptive name, for example e1ef34ca-cdef-463d-9c3f-94aa606bc6ab.wmv. Because of this I set the default behavior of the script to use the RSS item title as the file name.

UrlRegex – This is the regular expression that will be used to search for the video URL from the HTML code from each RSS item link. You can re-use the default regex and replace “wmv” with for example “mp4” if you want to download the MP4-versions of the videos. If you are interested in learning about Regular Expressions, I can recommend the book “Master Regular Expressions” by Jeffrey E.F. Friedl. If you want a tool to help you build the regular expression I can recommend RegexBuddy.

Verbose – This is not a parameter I have added, it is one of the common parameters in PowerShell which I want to highlight since I have added some verbose information. For example if the regular expression does not match, you can see it in the verbose output. This is a switch parameter, so you can add “-Verbose” to the script parameters to use it. You can also read more about the Verbose parameter in the about_CommonParameters help topic.

The download process

Initially when creating the script I started using the DownloadFile method of the Net.WebClient class in .NET. This worked fine, but did not provide any progress status during download. This makes it hard for the user of the script to know how long the download will take, and if anything is happening at all. I then turned to Background Intelligent Transfer Service (BITS), and the Start-BitsTransfer cmdlet which provides progress status as well as other features. For some reason the BITS jobs failed with the error message “HTTP status 404: The requested URL does not exist on the server.”. I am not sure why, but this may be because the server-side on TechNet Edge downloads does not support the necessary HTTP Requirements.

I then got a tip from Joel Bennett about his Get-WebFile function available on PoshCode. This function met my requirements, and is included at the top of the script.

The script will check the destination folder to see if the file is already downloaded, which means you can run the script several times without downloading files you already have. This is also useful when running the script as a scheduled task, which may be of interest if you want to automatically download new videos in a specific category.

Related resources

MMS 2012 Download Sessions – Offline Viewing (PowerShell script to download sessions from MMS 2012)


May 6, 2012 - Posted by | Scripting, TechNet Edge, Windows PowerShell |


  1. […] by Jan Egil Ring that allows you to download content from TechNet edge using PowerShell is locate here. It's similar to the script for downloading content from MMS […]

    Pingback by 60 Days to MCSE - Week 4 Check In - 60 Days to MCSE - Blog - 60 Days to MCSE - Born to Learn | May 15, 2012 | Reply

  2. […] Download TechNet Edge videos with PowerShell […]

    Pingback by Episode 187- Teresa “ScriptingWife” Wilson and Staci “HalsWife” Rottenberg « PowerScripting Podcast | May 28, 2012 | Reply

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: