Quantcast
Channel: PowershellTaskForce » Products
Viewing all articles
Browse latest Browse all 12

Download the Channel 9 videos of DSC virtual academy course with PowerShell

$
0
0

As you might have noticed the Virtual Academy courses with getting started and Advanced DSC with Jason Helmick and Jeffrey Snover have been released and also the videos are available from Channel 9

Is there a better way than to use PowerShell to download them? Naaaaa

I have customised a script that I used for downloading Teched content and now changed to the DSC videos so with this and BITS and of course a nice and powerful broadband connection you have the files within a blink. It is a function and the plan was to upload it to the PowerShell module gallery but I have to be invited and will update the post when this has been done and you can find it there!

Screen Shot 2015-03-13 at 12.09.20

<#
.Synopsis
   A powershell function to download the DSC virtual academy videos 
.DESCRIPTION
   Long description
.EXAMPLE
   Download-DSCvideos -All -Dest "c:\DSCrocks"
.EXAMPLE
   
.NOTES
Author: Niklas Akerlund 20150312 
Code borrowed from Peter Schmidt (Exchange MVP, blog: www.msdigest.net) DownloadTechEdEurope14VideoAndSlides.ps1
#>
function Download-DSCvideos
{
[CmdletBinding()]
param(
  [switch]$Basic,
  [switch]$Advanced,
  [switch]$All,
  [switch]$MP4,
  [string]$Dest='C:\DSC')

# Check if the folder exists
if(!(Get-Item $Dest -ErrorAction Ignore))
{
  New-Item -Path $Dest -ItemType Directory
}
$vsessions = @()

if($Basic -or $All){
  $vsessions = Invoke-RestMethod 'http://channel9.msdn.com/Series/Getting-Started-with-PowerShell-Desired-State-Configuration-DSC/feed/mp4high' | Sort-Object link
}

if($Advanced -or $All){
  $vsessions += Invoke-RestMethod 'http://channel9.msdn.com/Series/Advanced-PowerShell-Desired-State-Configuration-DSC-and-Custom-Resources/feed/mp4high' | Sort-object link
}

if($MP4){
  foreach ($vsession in $vsessions){
      
      $folder = $vsession.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "").Replace("|", "").Replace('"',"").Replace("*","")
		  $folder = $folder.substring(0, [System.Math]::Min(100, $folder.Length))
		  $folder = $folder.trim()
      $folder = $Dest + "\" + $folder
      if(!(Get-Item $folder -ErrorAction Ignore)){
          New-Item -Path $folder -ItemType Directory
      }
      [string]$video = $vsession.GetElementsByTagName('enclosure').url
      $videoname = $video.Split("/")[-1]
      if(!(get-item ($folder +"\" +$videoname) -ErrorAction Ignore)){
        Start-BitsTransfer -Source $video -Destination $folder
      }else{
        Write-Output  "$videoname video already downloaded"
      }
  }
}
}

If you already have downloaded some of the files it will check if you have those in the folder and not start to download them again.

Screen Shot 2015-03-13 at 12.11.29

So go and get your videos for some weekend PowerShell DSC love ;-)


Viewing all articles
Browse latest Browse all 12

Trending Articles