Download-DSCvideos.psm1
<#
.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 } $psessions = @() $vsessions = @() #$ = 'C:\techedtest' if($Basic -or $All){ #$psessions = Invoke-RestMethod 'http://channel9.msdn.com/Events/TechEd/Europe/2014/RSS/slides' | where comments -cmatch "CDP" $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){ #$psessions += Invoke-RestMethod 'http://channel9.msdn.com/Events/TechEd/Europe/2014/RSS/slides' | where comments -cmatch "WIN" $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" } } } } |