Download file with PowerShell

Downloads and saves a file in the current working directory of PowerShell.

Can you use the previous working directory ($pwd) or change it to a fixed location: “C:\Download” or by first change the directory in PowerShell.
Examples of changing the directory:

$storageDir = $pwd

# or:

$storageDir = "C:\Downloads"


cd C:\Users\Teusje\Documents
$storageDir = $pwd


Below is the script to download a file via PowerShell. You can run it directly in PowerShell:

$storageDir = $pwd
$webclient = New-Object System.Net.WebClient
$url = ""
$file = "$storageDir\myNewFilename.jpg"

Have fun! 😉


16 thoughts on “Download file with PowerShell

  1. Pingback: Downloading files with PowerShell using the BitsTransfer module | Teusje

  2. article was just what I needed. However, pwd often means ‘present working directory’ in the *nix world, so that may be something to keep in mind, if only for the sake of posterity.

  3. pwd is “print working directory,” not “previous”. It’s the current directory,just like in unix-like shells. E.G.

    PS P:\> pwd

  4. Woww!!! Thank You!!!! And just have to finish it with Start-process $storageDir\myNewFilename if it executable thats work .. Do somebody can help me for other script?

  5. $client = New-Object System.Net.WebClient
    $client.DownloadFile($url, $path)
    (new-object System.Net.WebClient).DownloadFile( $url, $path)

  6. ※画像はイメージになりますいつでもフレッシュなフルーツをお手軽にもぎたて果実のジューシーさがうれしい、フレッシュフルーツ。メンズ ワイシャツ ブランド

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s