Downloading Information from Internet (Part 8)

by Apr 24, 2018

In the previous tip we illustrated how to download files from the internet using Invoke-WebRequest. However, this works for HTTP addresses only. Once you start using HTTPS addresses, it fails:

$url = "https://github.com/PowerShellConferenceEU/2018/raw/master/Agenda_psconfeu_2018.pdf" $destination = "$home\agenda.pdf" Invoke-WebRequest -Uri $url -OutFile $destination -UseBasicParsing Invoke-Item -Path $destination 

The (simple) solution is to run this line first:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 

Once you do this, the previous code runs just fine and downloads the psconf.eu agenda in PDF format on your desktop, then tries to open the file.

Twitter This Tip! ReTweet this Tip!