≡ Menu

Powershell Script to Download MMS session files

The Midwest Management Summit (MMS) completed earlier this week in Minneapolis, MN. Great sessions were given on System Center products, PowerShell, SQL, and other related technologies. I am thankful for the hard work of the Minnesota System Center User Group (MNSCUG) for organizing it, as well as the Windows Management User Group (WMUG) for the pass to the conference.

Below is a quick PowerShell script I wrote for downloading all of the session files. It iterates through the schedule on mms.sched.org, and downloads the attachment links from sched.org to session folders in c:\temp.  You can edit the base location for the download.  It will not download it again if it finds the file in the download location, so you can rerun it to check for additional attachments that have been added.

Get it: download-mms2014files.ps1

##############################################
#                                            #
# File:     download-mms2014files.ps1        #
# Author:   Duncan Russell                   #
#           http://www.sysadmintechnotes.com #
#                                            #
##############################################

$baseLocation = 'c:\temp'

Clear-Host
$uri = 'http://mms2014.sched.org'
$sched = Invoke-WebRequest -Uri $uri -WebSession $mms
$links = $sched.Links
$links | ForEach-Object {
    if(($PSItem.href -like '*event/*') -and ($PSItem.innerText -notlike '*birds*'))
    {
        $eventUrl = $PSItem.href
        $eventTitle = $($PSItem.innerText -replace "full$", "") -replace "filling$", "" 
        "Checking session '{0}' for downloads" -f $eventTitle
        $eventTitle = $eventTitle -replace "\W+", "_"
        
        $event = Invoke-WebRequest -Uri $($uri + $eventUrl)
        $eventLinks = $event.Links

        $eventLinks | ForEach-Object {
            $eventFileUrl = $PSItem.href;$filename = $PSItem.innerText;if($eventFileUrl -like '*hosted_files*'){
                $downloadPath = $baseLocation + '\mms2014\' + $eventTitle
                $outputFilePath = $downloadPath + '\' + $filename
                if((Test-Path -Path $($downloadPath)) -eq $false){New-Item -ItemType Directory -Force -Path $downloadPath | Out-Null}
                if((Test-Path -Path $outputFilePath) -eq $false)
                {
                    "...attempting to download '{0}'" -f $filename

                    Invoke-WebRequest -Uri $eventFileUrl -OutFile $outputFilePath -WebSession $mms;$doDownload=$false;
                    Unblock-File $outputFilePath
                    $stopit = $true
                }
            }
        }
    }
}

Get it: download-mms2014files.ps1

{ 8 comments… add one }
  • Gary November 15, 2014, 10:25 pm

    Thanks, I’ll be using this Monday morning to pull down all the content. What a great conference.

  • Charbel November 16, 2014, 9:45 am

    What about the recording please?

    Thanks,
    Charbel

    • Duncan Russell November 16, 2014, 4:38 pm

      Charbel, the sessions were not recorded. You had to view the sessions in person.

  • Dave November 17, 2014, 6:38 am

    Thanks Duncan,
    You just saved me a bunch of time with this great PowerShell script !
    Dave

    • Duncan Russell November 17, 2014, 7:53 pm

      Dave, I wrote it to save *me* a bunch of time, so I get it. 🙂

  • Luke November 21, 2014, 10:51 am

    This was superb. It saved me so much time. Thank you!

Leave a Comment