首页 > 解决方案 > cURL 无法识别命令行参数 (Windows 10)

问题描述

不确定我做错了什么,但是我尝试传递给 curl 的任何命令行参数(使用双破折号)都被解释为 url。运行curl --help

curl : The remote name could not be resolved: '--help'
At line:1 char:1
+ curl --help
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

使用单个破折号似乎可以解释 url 参数,但它没有找到某些参数。运行curl -sSL

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'sSL'.
At line:1 char:6
+ curl -sSL
+      ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

从https://curl.se/windows/下载的 curl 二进制文件

标签: windowscurl

解决方案


您可以在这里找到答案:通过 powershell 运行 curl - 如何构造参数?

“在 PowerShell 中,curl 是 Invoke-WebRequest cmdlet 的内置别名。别名在命令解析中具有优先权。要解决您的问题,请更具体地说,使用 curl.exe 而不是 curl,因此命令不会解析为别名”


推荐阅读