Thursday, July 27, 2017

Windows PowerShell wget equivalent

Windows lacks useful tools that Linux and Unix have, but with the introduction of PowerShell things become more useful and easier to work with.

To implement wget in PowerShell and have it download any type of file use the following;

$webConnect = new-object System.Net.WebClient

$webConnect.DownloadFile("http://your.web.location/somefile.ext",".\localfile.ext")


The above example will download the file into the current directory.  somefile.ext could be for example a zip file such as mydocs.zip, and localfile.ext would simply be mydocs.zip.

If you omit the 2nd argument then the content of the URL will be output to the screen (stdout).