Victor Vogelpoel

Excellence is in the details

PowerShell: Download SharePoint Connect 2014 Amsterdam slides from (using SlideShare API)

Leave a comment

Last November I had the pleasure of attending the SharePoint Connect 2014 Amsterdam conference at De Meervaart Theatre. Organizer NC Communication was nice enough to share the slides on at with the prefix title “SPCA2014”.

There are about 25 slide decks and the amount of clicking to download them is daunting! Time for a PowerShell script!

I devised the following PowerShell script for downloading these slides using the SlideShare API. If you want to run it for yourself, you’ll have to apply for an API key at and insert the credentials in the script.

And I had so much fun that I started a PowerShell module for talking with the SlideShare API. Stay tuned…

$slideshareUser = 'nccomms'
$slidedeckTitleFilter = 'SPCA2014*'

# Folder to download the slides to
$downloadfolder = 'C:\TEMP\SharePointConnect2014'

# Personal SlideShare API keys;
# apply for a key here:
$slideShareAPIKey = 'YOUR_API_KEY'  #PRIVATE
$slideShareSharedSecret = 'YOUR_SHARED_SECRET'

# Unix timestamp
$ts = [int][double]::Parse($(Get-Date -date (Get-Date).ToUniversalTime()-uformat %s))

# Create an SHA1 hash from the concatenation of the shared secret and the timestamp
$hash = ([System.Security.Cryptography.HashAlgorithm]::Create('SHA1').ComputeHash((New-Object System.Text.UTF8Encoding).GetBytes("$slideShareSharedSecret$ts")) | foreach { $_.ToString("x2") }) -join ''

$slideshareAPIGetSlideShowsForUserUri = "$slideshareUser&limit=9999&api_key=$slideShareAPIKey&hash=$hash&ts=$ts"

# Now query the SlideShare API for user NCCOMMS slides
Write-Host "Query SlideShare API: $slideshareAPIGetSlideShowsForUserUri"
$spa2014SlideData = Invoke-RestMethod -uri $slideshareAPIGetSlideShowsForUserUri

if ($spa2014SlideData.SlideShareServiceError)
    Write-Host "ERROR while calling SlideShare API:" -ForegroundColor RED
    $spa2014SlideData.SlideShareServiceError.Message | foreach { Write-Host $_.'#text'  -ForegroundColor RED }
    Write-Host "Downloading the slide decks..."

    # Parsing the query results 
    foreach ($slidedeckEntry in ($spa2014SlideData.User.Slideshow | where { $_.Title -like $slidedeckTitleFilter }))
        # Now process each slideshow entry

        # Get the SlideShare PDF download url (which points to Amazon S3)
        $sourceFile = $slidedeckEntry.DownloadUrl

        # Extract the filename
        $filename = (New-Object Uri($sourceFile)).Segments | select -last 1 # get filename part of the url
        $destFilePath = (Join-Path $downloadfolder $filename)

        Write-Host "From `"$SourceFile`"`nTo `"$destFilePath`""

        # And download the deck file to the specified download folder
        Invoke-WebRequest -Uri $sourceFile -OutFile $destFilePath

    Write-Host "Completed downloading the slide decks."

Author: Victor Vogelpoel

Dad, Technical specialist, PowerShell architect, photographer and just a guy whose life happens while trying planning it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s