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 = ""
$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 agenda in PDF format on your desktop, then tries to open the file.

Twitter This Tip! ReTweet this Tip!