Thanks to Michel de Rooij on TechNet gallery for posting this slick script where you can download TechNet content locally to your machine.
https://gallery.technet.microsoft.com/Ignite-2016-Slidedeck-and-296df316
I wanted to select which videos to download, and wrote this powershell script to use out-gridview to download content. It calls the script above.
Usage:
You can run the command directly from powershell, just cut and paste this command:
iwr https://gist.githubusercontent.com/keithga/cb124fa3d2f96ac58470831c52d359a7/raw/8040ddaf971a27f0b35fd4b5e9c131048d29e8a5/get-Ignite2017Content.ps1 | % Content | Iex
Comments:
- Will download and cache the content locally so you can re-run the script repeatedly without having to wait to parse the website.
- Will then display all the sessions in the PowerShell Out-GridView. Out-gridview is powerful.
- Then will ask If you want to save the list to a *.html file for online viewing later.
- Will also ask if you want to save the offline content to a local file.
The script:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Script to assist finding content to download from MS Ignite 2017 | |
Will use the script Get-IngiteSession.ps1 from: https://gallery.technet.microsoft.com/Ignite-2016-Slidedeck-and-296df316 | |
#> | |
[cmdletbinding()] | |
param( | |
[string] $URI = 'https://gallery.technet.microsoft.com/Ignite-2016-Slidedeck-and-296df316/file/180223/1/Get-IgniteSession.ps1', | |
[string]$DownloadFolder = "$ENV:SystemDrive\Ignite", | |
[string[]] $IgniteProperties = @( 'sessionCode', 'title', 'abstract', 'dayOfTheWeek', 'topics', 'format', 'audience', 'levels', 'personas', 'durationInMinutes', 'products', 'tags', 'speakerNames', 'speakerIds', 'slideDeck', 'onDemand', 'downloadVideoLink' ) | |
) | |
Function Remove-InvalidFileNameChars { | |
param( | |
[Parameter(Mandatory=$true, | |
Position=0, | |
ValueFromPipeline=$true, | |
ValueFromPipelineByPropertyName=$true)] | |
[String]$Name | |
) | |
$invalidChars = [IO.Path]::GetInvalidFileNameChars() -join '' | |
$re = "[{0}]" -f [RegEx]::Escape($invalidChars) | |
return ($Name -replace $re) | |
} | |
if ( -not ( test-path $DownloadFolder ) ) { | |
new-item –ItemType directory –Path $DownloadFolder –ErrorAction SilentlyContinue –force | out-null | |
} | |
#region Download and Cache session list | |
############################## | |
$IgniteCache = join-path $DownloadFolder 'IgniteSessionCache.xml' | |
if ( -not ( test-path $IgniteCache ) ) { | |
Write-verbose "Get meta-data on sessions" | |
$LocalSCript = Join-Path $DownloadFolder (split-path $URI –leaf) | |
if ( -not ( test-path $LocalScript ) ) { | |
write-verbose "download Script $URI" | |
Invoke-WebRequest –UseBasicParsing –Uri $URI –OutFile $LocalScript | |
} | |
$IgniteList = & $LocalScript –InfoOnly | |
remove-item –Path $LocalScript –ErrorAction SilentlyContinue | out-null | |
$IgniteList | Export-Clixml –Path $IgniteCache | |
} | |
else { | |
$IgniteList = Import-Clixml –path $IgniteCache | |
} | |
#endregion | |
#region Parse the list and display in out-gridview | |
############################## | |
$MyList = $igniteList | | |
# We are only intrested in presentations with content. | |
where { $_.SlideDeck -or $_.DownloadVideoLink -or $_.OnDemand } | | |
# Don't display any repeat sessions | |
where { ! $_.SessionCode.EndsWith('R') } | | |
select –Property $IgniteProperties | | |
Out-GridView –Title 'Select Items to download (use ctrl to select more than one)' –OutputMode Multiple | |
$count = $MyList | measure-object | % Count | |
write-host "Selected $count Items" | |
if ( $Count -eq 0 ) { exit } | |
#endregion | |
#region Display OnDemand content | |
############################## | |
if ( [System.Windows.MessageBox]::Show("Found $Count Items`r`n`r`nOK to generate ONDemand link?",'Ignite Download','YesNo','Info') -eq 'yes' ) { | |
write-host "List of OnDemand Content: " | |
$MyList | ? { $_.OnDemand } | ft –Property Title,onDemand | out-string –Width 200 | write-host | |
$MyList | ? { ! $_.OnDemand -and $_.slideDeck } | ft –Property Title,slideDeck | out-string –Width 200 | write-host | |
"<html><head><title>OnDemand Ignite Session List</title></head><body>" > $DownloadFolder\OnDemandList.html | |
$MyList | ? { $_.OnDemand } | % { "<a href=""$($_.onDemand)"">$($_.SessionCode) – $($_.Title)</a></br>" } >> $DownloadFolder\OnDemandList.html | |
"</br></br>" >> $env:temp\OnDemandList.html | |
$MyList | ? { ! $_.OnDemand -and $_.slideDeck } | % { "<a href=""https:$($_.slideDeck)"">$($_.SessionCode) – $($_.Title)</a></br>" } >> $DownloadFolder\OnDemandList.html | |
"</body></html>" >> $DownloadFolder\OnDemandList.html | |
start $DownloadFolder\OnDemandList.html | |
} | |
#endregion | |
#region Download content | |
############################## | |
if ( [System.Windows.MessageBox]::Show("Found $Count Items`r`n`r`nOK to Download to: $DownloadFolder",'Ignite Download','YesNo','Info') -eq 'yes' ) { | |
$MyList | | |
foreach-object { | |
if ( $_.DownloadVideoLink ) { | |
[PSCustomObject] @{ Source = $_.DownloadVideoLink; Destination = join-path $DownloadFolder ( Remove-InvalidFileNameChars "$($_.SessionCode) – $($_.Title).mp4" ) } | |
} | |
elseif ( $_.SlideDeck ) { | |
[PSCustomObject] @{ Source = [System.Web.HttpUtility]::UrlDecode( $_.Slidedeck.replace('//view.officeapps.live.com/op/embed.aspx?src=','') ) ; | |
Destination = join-path $DownloadFolder ( Remove-InvalidFileNameChars "$($_.SessionCode) – $($_.Title).pptx" ) } | |
} | |
} | | |
where-object { -not ( test-path $_.Destination ) } | | |
start-BitsTransfer | |
} | |
#endregion | |
#cleanup | |
#remove-item -Path $IgniteCache -ErrorAction SilentlyContinue | out-null |