Share this article
Improve this guide
How to easily download a file with PowerShell
3 min. read
Published onNovember 18, 2022
published onNovember 18, 2022
Share this article
Improve this guide
Read our disclosure page to find out how can you help Windows Report sustain the editorial teamRead more
PowerShellis a handy, free task automation tool provided by Microsoft that lets you manage and, as you might’ve guessed from its name, automate your tasks on Windows with ease. However, that’s not all, though.
You can, for instance, also download internet files thanks to your PowerShell app. In this piece, we dive into the most straightforward method to get files with PowerShell. Here’s how you can get started.
How to download a file with PowerShell
One of the most common ways to download your file with PowerShell is by using the URL of the file you’d like to download. That’s precisely what we’ll be covering in this short guide. To complete your download, you’ll be using theInvoke-WebRequestcmdlet.
Also, before we head to the actual download, we’d also want to specify that you’ll need a specific destination where you can store the downloaded file. You’ll have to add a particular parameter to your cmdlet file.
Here’s what the complete syntax will look like:
Depending on where you’d like to download the files from and the place you’d like to put your files, replace thesourceanddestinationvariable with the URL of the file you’d like to download and the place you’d like to download it to.
After you’ve launched the PowerShell, type in the following dummy command. This is what it will look like:
Here, the command downloads the file source from‘https://www.majorgeeks.com/files/details/4diskclean_free.html/4dskcln.exe’, and then saves it to‘c:\programfiles\newfolder’.
This should download the required files fairly simply. However, in some cases, you might get asked for login access before you can proceed with the download. You can do that by adding the-Credentialparameter. Just add the following command to your code:
Here’s what the complete command will look like now:
That’s it. Your download will begin.
Downloading a file with PowerShell without any hassles
Downloading files with PowerShell doesn’t have to be super complicated. With the method we’ve explained above, we believe it was a breeze for you. However, don’t hit the brakes just now.PowerShell packs tons of commandsthat can help you do just about anything on your PC. So, don’t stop just now; keep exploring things out there.
Radu Tyrsina
Radu Tyrsina has been a Windows fan ever since he got his first PC, a Pentium III (a monster at that time).
For most of the kids of his age, the Internet was an amazing way to play and communicate with others, but he was deeply impressed by the flow of information and how easily you can find anything on the web.
Prior to founding Windows Report, this particular curiosity about digital content enabled him to grow a number of sites that helped hundreds of millions reach faster the answer they’re looking for.
User forum
0 messages
Sort by:LatestOldestMost Votes
Comment*
Name*
Email*
Commenting as.Not you?
Save information for future comments
Comment
Δ
Radu Tyrsina