You can manage and, as its name implies, automate your Windows tasks with ease by using PowerShell, a free tool provided by Microsoft. With your PowerShell app, you can, for instance, download internet files. Using PowerShell, we’ll explore the most straightforward way to get files.

Using PowerShell to download a file

Using the URL of the file you would like to download is one of the most common ways to download it with PowerShell. This short guide will cover exactly that. In order to complete your download, you’ll use the cmdlet Invoke-WebRequest.

We also want to clarify that you will need a specific destination where you can store the downloaded file before we proceed to the actual download. Your cmdlet file will need a particular parameter.

Prerequisite Before Download the File

The path and URL should be stored in variables as a best practice. The variables $URL and $Path will be used in this article. You will need to replace the values with your own, but here is an example of how you can declare these variables.

  • $URL = “https://www.androidgreek.com/wp-content/uploads/2022/01/AndroidGreek-LOGO-V2.1.png”
  • $Path=”C:\New folder\AndroidGreek-LOGO-V2.1.png”

In addition to the file system location, the path contains the filename for the file you will download. It is not necessary for this filename to match the filename within the URL. It is possible to rename a downloaded file by using a different filename.

Here to Guide download a file Using PowerShell

For downloading files, I usually use the Invoke-WebRequest cmdlet. However, any of the three cmdlets I show you will work. It is simple to use the Invoke-WebRequest cmdlet. The following is an example of a download command:

Invoke-WebRequest -URI $URL -OutFile $Path