Posted: . At: 1:00 PM. This was 9 years ago. Post ID: 7866
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

How to perform the same task as wget using Windows 10 and Powershell 5.0.

The Windows 10 Powershell command prompt has a cmdlet named Invoke-WebRequest, this allows a user to download a link using Powershell. This will download a web link with a very fast transfer rate. Making this a very good way to retrieve a web link. Below is an example downloading a link from kernel.org. I am using the wget alias as it is easier to remember.

wget https://www.kernel.org/pub/software/editors/uemacs/em-4.0.15-lt.tar.gz -OutFile Desktop\uemacs.tar.gz

This will download the linked file from kernel.org with a fast transfer rate.

Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.
 
PS C:\Users\Homer> wget https://www.kernel.org/pub/software/editors/uemacs/em-4.0.15-lt.tar.gz -OutFile Desktop\uemacs.tar.gz
PS C:\Users\Homer> cd .\Desktop
PS C:\Users\Homer\Desktop> dir
 
 
    Directory: C:\Users\Homer\Desktop
 
 
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       27/10/2014  12:54 PM         209681 uemacs.tar.gz

This is a great way to get a file from a website using Powershell. I am using Powershell 5.0 on Windows 10 build 9860 and it works a treat.

Yet another example. Not specifying an output filename.

PS C:\Users\Corporal Kerry> wget securitronlinux.com/linux/maps/debian2.jpg
 
 
StatusCode        : 200
StatusDescription : OK
Content           : {255, 216, 255, 224...}
RawContent        : HTTP/1.1 200 OK
                    Connection: keep-alive
                    CF-Cache-Status: MISS
                    Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
                    CF-RAY: 47014628cca865b1-SYD
                    Accept...
Headers           : {[Connection, keep-alive], [CF-Cache-Status, MISS], [Expect-CT, max-age=604800,
                    report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"], [CF-RAY,
                    47014628cca865b1-SYD]...}
RawContentLength  : 224494

So, the average windows user can download files as easily as a Linux user, with the command line. This is very useful in a Powershell script, or just an alternative to using Firefox to visit a site just to download one single file. This shows the power of the new Powershell scripting on Windows. Rivalling Linux for scripting ability.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.