18 Answers
18

GNU Wget is a free network utility to retrieve files from the World
Wide Web using HTTP and FTP, the two most widely used Internet
protocols. It works non-interactively, thus enabling work in the
background, after having logged off.

If you need to specify credentials to download the file, add the following line in between:

$client.Credentials = Get-Credential

A standard windows credentials prompt will pop up. The credentials you enter there will be used to download the file. You only need to do this once for all the time you will be using the $client object.

@BrainSlugs83, absolutely, but many, many, people are still using XP. It's merely something to bear in mind.
– ArranMay 7 '13 at 8:08

4

@BrainSlugs83, you underestimate the amount of people still on older Windows systems. I don't understand the issue, I pointed out it's only on Vista upwards. People can choose to ignore it, or say "hey thanks!", but you....? If you have an issue, create a chat and we can talk. Someone with rep (like you) should realise here is not the place for this discussion.
– ArranJun 4 '13 at 21:17

This doesn't work with redirects on sourceforge (and possibly other sites), as opposed to System.Net.WebClient. However you can make Invoke-WebRequest work by adding -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox.
– Ela782Jan 7 '16 at 12:22

Is there an option to see the progress of the download?
– Franklin YuNov 13 '17 at 19:24

@FranklinYu the progress will show if the file is large enough
– Steven PennyNov 13 '17 at 19:55

Interesting. That is one clumsy piece of software compared to wget.
– Matt HMar 28 '12 at 21:36

2

Note that It doesn't ship with Windows XP, and maybe not with other versions either.
– Ian DunnMay 22 '12 at 23:06

12

Update: BITSAdmin is deprecated and is not guaranteed to be available in future versions of Windows. Administrative tools for the BITS service are now provided by BITS PowerShell cmdlets.
– nulldev07Sep 28 '12 at 5:49

why the downvote? this looks okay to me and is a direct response to the question. Yes it's clunky and could use improvement, like escaping ampersands (&) in the url, but it works as is.
– matt wilkieApr 24 '13 at 5:02

and it will seem like it works but what it is actually doing is just
using cURL as an alias. In the above instance, what will happen is
that you will just get the headers instead of the file itself.

Aliases in PowerShell allow you to create shortcuts for longer commands so you don’t have to type them out all of the time.

If you type in the command Get-Alias, it will give you a list of all the Aliases that are used in PowerShell. As you can see, the curl command just calls the Invoke-WebRequest command. They are similar but not the same which is why the above request does not work for us.

To get this to work properly in PowerShell the easiest way is to use variables and the -OutFile argument as shown here:

This syntax will download the full contents of the target file azuredeploy.json to the local file newfile.json

The primary advantage is that it is built into Powershell itself so this code will execute directly with no downloads or any other extra file creations are required to make it work on any modern version of Windows.

Failing that, Wget for Windows, as others have pointed out is definitely the second best option. As posted in another answer it looks like you can download Wget all by itself, or you can grab it as a part of Cygwin or MSys.

If for some reason, you find yourself stuck in a time warp, using a machine that doesn't have PowerShell and you have zero access to a working web browser (that is, Internet Explorer is the only browser on the system, and its settings are corrupt), and your file is on an FTP site (as opposed to HTTP):

start->run "FTP", press "OK".

If memory serves it's been there since Windows 98, and I can confirm that it is still there in Windows 8 RTM (you might have to go into appwiz.cpl and add/remove features to get it). This utility can both download and upload files to/from FTP sites on the web. It can also be used in scripts to automate either operation.

This tool being built-in has been a real life saver for me in the past, especially in the days of ftp.cdrom.com -- I downloaded Firefox that way once, on a completely broken machine that had only a dial-up Internet connection (back when sneakernet's maximum packet size was still 1.44 MB, and Firefox was still called "Netscape" /me does trollface).

A couple of tips: it's its own command processor, and it has its own syntax. Try typing "help". All FTP sites require a username and password; but if they allow "anonymous" users, the username is "anonymous" and the password is your email address (you can make one up if you don't want to be tracked, but usually there is some kind of logic to make sure it's a valid email address).

+1 for thinking of command line ftp! However wget and powershell were both mentioned well before you joined the party, so -1 there. :-/
– matt wilkieApr 24 '13 at 5:08

The other powershell answers I saw were all multi-liners and/or had some code smell to them -- this is a short & simple one liner to download a file. -- Also I wanted to provide an answer that covered all the bases. :-)
– BrainSlugs83Jan 12 '16 at 0:20

I'm not sure why you have two question marks in the destination file C:\tmp\file.tx??t
– PloniFeb 7 '18 at 23:44

You can get WGet for Windows here. Alternatively you can right click on the download link of the item you want to download and choose Save As. This will download the file and not open it in the assigned application.

One interesting difference from conventional wget (more at that link): You can't simply use the greater-than to pipe to a file. wget in PowerShell is just a convenience wrapper for Invoke-WebRequest, and you need to use its syntax to write to a file.

you can manage with unxutils but it's old, it uses an old version of wget. gnuwin32 is the thing to use. not quite as convenient to install and not as easy to find things, but it has much more than unxutils too.
– barlopOct 5 '11 at 19:31

Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).