powershell download file code example

Example 1: how to download file in powershell

$url = "http://mirror.internode.on.net/pub/test/10meg.test"
$output = "$PSScriptRoot\10meg.test"

Invoke-WebRequest -Uri $url -OutFile $output

Example 2: powershell download a file from url

$Link = "https://www.7-zip.org/a/7z1900-x64.msi"
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("$Link","$env:USERPROFILE\Downloads\7zip1900.msi");

Example 3: powershell download file

Invoke-WebRequest URL -OutFile c:\file.ext

Tags:

Misc Example