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. 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 with the actual download. Your cmdlet file will need a particular parameter.
Prerequisites Before Downloading 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.
In addition to the file system location, the path contains the filename for the file you will download. This filename does not need to match the filename in the URL. It is possible to rename a downloaded file by using a different filename.
Here is a guide is a guide to downloading 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-web-request cmdlet. The following is an example of a download command:
Invoke-WebRequest -URI $URL -OutFile $Path