Wget and curl functionality via PowerShell on a Windows system

If you are accustomed to using the wget or cURL utilities on Linux or Mac OS X to download webpages from a command-line interface (CLI), there is a Gnu utility, Wget for Windows , that you can download and use on systems running Microsoft Windows. Alternatively, you can use the Invoke-WebRequest cmdlet from a PowerShell prompt, if you have version 3.0 or greater of PowerShell on the system. You can determine the version of PowerShell on a system by opening a PowerShell window and typing $psversiontable. E.g., in the example below from a Windows 10 system, the version of PowerShell is 5.1.15063.674.

Learning Windows PowerShell
Learning Windows PowerShell
1x1 px

PS C:\Users\public\documents> $psversiontable

Name                           Value
----                           -----
PSVersion                      5.1.15063.674
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.674
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3

PS C:\Users\public\documents>

If you have version 3.0 or later, you can use wget or curl as an alias for the Invoke-WebRequest cmdlet, at least up through version 5.x. E.g., if I want to download the home page for the website example.com to a file named index.html, I could use the command wget -OutFile index.html http://example.com at a PowerShell prompt. Or I could use either of the following commands, instead:

curl -OutFile index.html http://example.com
Invoke-WebRequest -OutFile index.html http://example.com

If you don't want to download the page to the system, but just want to see the header information for the page. You can just specify the URL for the page as shown below.

Udemy - April2516-25off-sitewide120x600
PS C:\Users\public\documents> wget http://example.com

StatusCode        : 200
StatusDescription : OK
Content           : <!doctype html>
                        <title>Example Domain</title>

                        <meta charset="utf-8" />
                        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
                        <meta name="viewport" conten...
RawContent        : HTTP/1.1 200 OK
                    Vary: Accept-Encoding
                    X-Cache: HIT
                    Content-Length: 1270
                    Cache-Control: max-age=604800
                    Content-Type: text/html
                    Date: Wed, 11 Oct 2017 02:28:12 GMT
                    Expires: Wed, 18 Oct 2017 02:28...
Forms             : {}
Headers           : {[Vary, Accept-Encoding], [X-Cache, HIT], [Content-Length, 1270], [Cache-Control,
Images            : {}
InputFields       : {}
Links             : {@{innerHTML=More information...; innerText=More information...; outerHTML=&lt;A
                    href="http://www.iana.org/domains/example">More information...</A>; outerText=More information...;
                    tagName=A; href=http://www.iana.org/domains/example}}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 1270

PS C:\Users\public\documents>

You can see syntax information for the cmdlet by typing Invoke-WebRequest -? at a PowerShell prompt.

PS C:\Users\public\documents> Invoke-WebRequest -?


    Invoke-WebRequest [-Uri] <uri> [-UseBasicParsing] [-WebSession <WebRequestSession>] [-SessionVariable <string>]
    [-Credential <pscredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>] [-Certificate
    <X509Certificate>] [-UserAgent <string>] [-DisableKeepAlive] [-TimeoutSec <int>] [-Headers <IDictionary>]
    [-MaximumRedirection <int>] [-Method {Default | Get | Head | Post | Put | Delete | Trace | Options | Merge |
    Patch}] [-Proxy <uri>] [-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-Body <Object>]
    [-ContentType <string>] [-TransferEncoding {chunked | compress | deflate | gzip | identity}] [-InFile <string>]
    [-OutFile <string>] [-PassThru]  [<CommonParameters>]


    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
        -- To download and install Help files for the module that includes this cmdlet, use Update-Help.
        -- To view the Help topic for this cmdlet online, type: "Get-Help Invoke-WebRequest -Online" or
           go to https://go.microsoft.com/fwlink/?LinkID=217035.

PS C:\Users\public\documents>