PoshCode Archive  Artifact [8bbf1de49b]

Artifact 8bbf1de49bc618b20049228939ef7b095228317beafd17c83f815c60f9a49cc5:

  • File Get-Ignite2015Video.ps1 — part of check-in [24e6759e8a] at 2018-06-10 14:02:47 on branch trunk — This function downloads sessions from Microsoft Ignite 2015. (user: mwjcomputing size: 1320)

# encoding: ascii
# api: powershell
# title: Get-Ignite2015Video
# description: This function downloads sessions from Microsoft Ignite 2015.
# version: 0.1
# type: function
# author: mwjcomputing
# license: CC0
# function: Get-Ignite2015Video
# x-poshcode-id: 5857
# x-archived: 2015-05-16T04:49:04
# x-published: 2015-05-12T13:05:00
#
#
function Get-Ignite2015Video {
  [CmdletBinding()]
  param (
    [Parameter(Mandatory=$True,ValueFromPipeline=$true)]
    [string]$Session,
    [string]$Path = "C:\ignite\2015-videos"
  )

  begin {
    # Generate File URL. Had to make sure video names were upper case.
    # Lower case urls don't work.
    $fileUrl = "http://video.ch9.ms/sessions/ignite/2015/$($Session.ToUpper()).mp4"

    Write-Verbose -Message "URL: $fileUrl"
    
    # Test to see if location to save files exists, if not create it.
    if(!(Test-Path $path)) {
      New-Item $path -ItemType directory -Force
    }

    # Load the BitsTransfer module
    Import-Module -Name 'BitsTransfer'
  }

  process {
    # Download video files.
    Start-BitsTransfer -Source $fileUrl -Destination "$path\$Session.wmv" -Description "Downloading file $Session from Ignite 2015."
  }

  end {
    # Remove BitsTransfer Module
    Remove-Module -Name 'BitsTransfer'
  }
}