如何使用Windows的wget、curl、iwr?

Windows

1 前言

一个问题,一篇文章,一出故事。
笔者最近新装了一台Windows 2019的系统(没有桌面),需要通过命令行下载文件,于是整理此文。

2 最佳实践

2.1 命令使用帮助

Get-Help wget

可见如下显示,

NAME
    Invoke-WebRequest

SYNTAX
    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>]


ALIASES
    iwr
    wget
    curl


REMARKS
    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.

注:从以上可知“iwr”、“wget”和“curl”只是“Invoke-WebRequest”命令的别名

2.2 使用范例

wget -Uri https://dldir1.qq.com/weixin/Windows/WeChatSetup.exe -OutFile WeChatSetup.exe
没有评论

发表回复

Windows
如何修改Windows的时区?

1 前言 一个问题,一篇文章,一出故事。 笔者由于需要使用命令设置Windows系统的时区,于是整理 …

Windows
如何熟悉微软的OAuth 2.0和OpenID Connect?

1 OAuth的基础知识 1.1 OAuth的简介 – OAuth即Open Autho …

cmd shell
如何bat免密码登录Windows?

1 前言 一个问题,一篇文章,一出故事。 笔者最近想通过bat自动登录Windows服务器,于是整理 …