How to download a file using PowerShell in Windows 10

Windows PowerShell in Windows 10, is a powerful tool whose capability set multiplies manifold over that of Command Prompt. It’s might even replace Command Prompt in near future as it offers more power and control over the operating system. Microsoft developed it for task automation and configuration management process. Based on the .NET Framework, it includes a command line interface and a scripting language.

Download a file using PowerShell

Today, we are going to use Windows PowerShell to download a file from Internet with the help of simple commands. Follow on to the below steps to know how to do so:

1. Open PowerShell console as administrator. To do this, press Windows Key on your keyboard and type in powershell. Right-click Windows Powershell (Desktop App) and select Run as administrator. Select Yes in the UAC window that pops up.

2. Now, you need to copy the link of the file you want to download using PowerShell. See the below image for example:

How to download a file using Windows PowerShell in Windows 10

3. Copy and paste the following command in Notepad.

$client = new-object System.Net.WebClient
$client.DownloadFile(“Download Link”,“File Destination\file name.file extension”)

4. Now, in the above command, replace Download Link with the link you copied in Step 2. Insert the download location path along with the name you want to save the file with, along with its extension in place of File Destination\file name.file extension. DO NOT remove the double quotes. See the below example for the modifying the command:

$client = new-object System.Net.WebClient
$client.DownloadFile(“http://thewindowsclub.thewindowsclub.netdna-cdn.com/wp-content/upload/2016/Windows-Explorer-Process-Task-Manager-600x405.png”,“C:\Users\Digdarshan\Pictures\TWC\Task-Manager.png”)

5. Now, copy the modified command and paste it in the PowerShell window. Hit Enter to download the file.

download a file using PowerShell

6. That’s it! You can navigate to the download folder path to find your file stored there.

How to download a file using Windows PowerShell in Windows 10

If downloading any file requires you to enter credentials of some sort like server login details etc., then you can use the following command to download the file in one shot:

$client = new-object System.Net.WebClient
$client.Credentials = Get-Credential
$client.DownloadFile(“http://thewindowsclub.thewindowsclub.netdna-cdn.com/wp-content/upload/2016/Windows-Explorer-Process-Task-Manager-600x405.png”,“C:\Users\Digdarshan\Pictures\TWC\Task-Manager.png”)

Let us know in the comments section below if you are facing any issue while trying to download the file.

Download this VPN to secure all your Windows devices and browse anonymously
Posted by on , in Category Windows with Tags
Driven by my immense passion for Windows & other Microsoft technologies, I love to keep myself abreast of the latest strides and swings in the world of technology. I am fond of traveling to mountains & love to help others with their technical or non-technical setbacks.

12 Comments

  1. Doron

    Exception calling “DownloadFile” with “2” argument(s): “An exception occurred during a WebClient request.”
    At line:1 char:1
    + $client.DownloadFile(“http://thewindowsclub.thewindowsclub.netdna-cdn …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

  2. Darshan

    Have you mentioned both the file URL and destination filename in the command? Can you please share the whole command that you have ran in PowerShell?

  3. Doron

    $client = new-object System.Net.WebClient
    $client.DownloadFile(“http://thewindowsclub.thewindowsclubco.netdna-cdn.com/wp-content/uploads/2016/06/Copy-Download-Link.png”,“C:UsersLDORONYDesktop1.png”)

  4. Digdarshan Kavia

    Try this command once:

    $client = new-object System.Net.WebClient
    $client.DownloadFile(“http://thewindowsclub.thewindowsclubco.netdna-cdn.com/wp-content/uploads/2016/06/Copy-Download-Link.png”,“C:UsersLDORONYDesktop1.png”)

    Make sure the quotes are placed correctly.

    Also, are you running powershell with administrative privileges?

  5. postanote

    As on who have lived with and loved PowerShell since it early Monad (it’s original name)…
    https://blogs.msdn.microsoft.com/powershell/2007/03/18/monad-manifesto-the-origin-of-windows-powershell
    http://www.jsnover.com/Docs/MonadManifesto.pdf

    This is ‘not’ a Windows 10 thing and it is really wrong to advertise it that way. You have been able to do this well before Windows 10 ever existed. Now, PoSH v5 in Windows… (and downloadable to earlier versions of Windows Client and Server) https://www.microsoft.com/en-us/download/details.aspx?id=50395 a watershed of new things to the table. But this is not one of them. a watershed of new things to the table. But this is not one of them.

  6. postanote

    PowerShell for Beginners “http://social.technet.microsoft.com/wiki/contents/articles/4307.powershell-for-beginners.aspx ”

    Getting Started with PowerShell 3.0 Jump Start
    https://mva.microsoft.com/en-us/training-courses/getting-started-with-powershell-3-0-jump-start-8276
    http://www.microsoftvirtualacademy.com/training-courses/advanced-tools-scripting-with-powershell-3-0-jump-start#fbid=wdBipBJLtCB

    What’s New in PowerShell v5 “https://mva.microsoft.com/en-US/training-courses/whats-new-in-powershell-v5-16434”

    Windows PowerShell Survival Guide “http://social.technet.microsoft.com/wiki/contents/articles/183.windows-powershell-survival-guide.aspx”

    YouTube “https://www.youtube.com/results?search_query=powershell+training”

  7. Darshan

    Indeed! This post was covered using Windows 10 (which is now the latest version) and I myself use it! It is nowhere implied that this particular method won’t work in earlier version of Windows 🙂

  8. Arkitech

    Why would you not use Invoke-WebRequest:

    Invoke-WebRequest -outfile https://urltofile.com/file.zip filenameyouwant.zip

  9. Doron

    running with administrative privileges and still the same issue

  10. Digdarshan Kavia

    Let’s define source and destination first, try this:

    $source = “http://thewindowsclub.thewindowsclubco.netdna-cdn.com/wp-content/uploads/2016/06/Copy-Download-Link.png”

    $destination = “C:UsersLDORONYDesktop1.png”

    $client = new-object System.Net.WebClient

    $client.DownloadFile($source, $destination)

  11. Digdarshan Kavia

    There can be numerous way of course. Just using one of those here 🙂

  12. Brooke Taylor

    I also have the same issue, what I’m trying to do is copy folders from our http server to a local server, here is what I have

    $source = “http://servername/serverupdates/deploy/Program%20Files/”
    $destination = “C:Program Files”
    $client = new-object System.Net.WebClient
    $client.DownloadFile($source, $destination)

Leave a Reply

Your email address will not be published. Required fields are marked *


9 + 3 =