How to download file from url in PowerShell

By FoxLearn 10/22/2024 9:15:48 AM   87
You can download a file from a URL using PowerShell with the Invoke-WebRequest or Invoke-RestMethod cmdlets.

How to Download File from URL in PowerShell?

Open your PowerShell command

powershell

Next, Define the URL and the destination path as shown below.

$url = "https://example.com/file.txt"
$destination = "C:\yourpath\file.txt"

# Download the file
Invoke-WebRequest -Uri $url -OutFile $destination

Run the script in your PowerShell.

This will download the specified file from the URL and save it to the designated location.