Home > PowerShell, Tutorials > Download File with a PowerShell One-Liner

Download File with a PowerShell One-Liner

December 11th, 2011 Leave a comment Go to comments

I was recently trying to automate some scripts on a linux box and I wanted to know if it was as simple to download a file in PowerShell as it is in linux: wget http://example.com/file.jpg

Well as it turned out, it wasn’t, but it wasn’t that difficult either. What we needed was too use the System.Net.WebClient class. There’s one thing to note, in PowerShell you can’t use a ~ (tilde) to reference your home directly, that is to say, you can’t download a file to ~\Desktop you will need to specify the full path, in my case C:\Users\Brangle\Desktop.

(new-object System.Net.WebClient).Downloadfile("http://wordpress.org/latest.zip", "C:\Users\Brangle\Desktop\wp-latest.zip")
  1. No comments yet.
  1. September 12th, 2020 at 01:38 | #1
  2. September 27th, 2020 at 02:52 | #2