Curl 错误:无法处理参数,因为参数名称“u”不明确

Pet*_*r_M 8 powershell curl

我正在尝试通过curl连接(在PowerShell 中), 但没有成功。

下面是我为了建立连接而插入的以下代码:

  curl -u <USER>:<PASSWORD> https://something.com
Run Code Online (Sandbox Code Playgroud)

但收到错误:

  Invoke-WebRequest : Parameter cannot be processed because the parameter name 'u' is ambiguous. 
  Possible matches include: -UseBasicParsing -Uri -UseDefaultCredentials -UserAgent.
Run Code Online (Sandbox Code Playgroud)

于是,我尝试在SO寻找解决方案,例如:

PowerShell 的 Invoke-RestMethod 相当于curl -u(基本身份验证)

在 64 位 Windows 上运行 cURL

在 GitHub 上: https: //github.com/PowerShell/PowerShell/issues/4351

但没有成功。我还在我的机器中重新安装了“curl”并尝试直接使用Invoke-WebRequest,但问题仍然存在。

我是 PowerShell 的新手,也许我在编写这些行时犯了一个错误,但是您对如何处理有什么建议吗?您认为有比 PowerShell 更好的命令提示符/CLI 来使用curl吗?

Yar*_*riv 5

正如@Maximilian Burszley 所写,PowerShell 中的curl 是另一个命令的别名,而不是您想要的curl 命令。

在我看来,最简单的解决方案是删除别名,然后curl命令将可用,而无需Get-Alias的开销,并且无需将curl与可执行文件的路径一起使用。

这是使用 Windows PowerShell 时删除curl 别名的命令:

Remove-item alias:curl
Run Code Online (Sandbox Code Playgroud)