3

I am trying to connect (in PowerShell) via curl but with no success.

Below is the following code I've inserting in order to establish the connection:

  curl -u <USER>:<PASSWORD> https://something.com

but got the error:

  Invoke-WebRequest : Parameter cannot be processed because the parameter name 'u' is ambiguous. 
  Possible matches include: -UseBasicParsing -Uri -UseDefaultCredentials -UserAgent.

So, I tried to look for a solution at SO, such as:

PowerShell's Invoke-RestMethod equivalent of curl -u (Basic Authentication)

Running cURL on 64 bit Windows

and on GitHub: https://github.com/PowerShell/PowerShell/issues/4351

But got no success. I also reinstalled the 'curl' in my machine and tried to use Invoke-WebRequest directly, but the problem persisted.

I'm new at PowerShell, maybe I'm doing a mistake when coding those lines, but do you have any suggestion how to deal with? Do you think there is a better Command Prompt/CLI than PowerShell to use curl?

Petter_M
  • 373
  • 2
  • 9
  • 18
  • 6
    `curl` is a built-in alias for `Invoke-WebRequest`. Make sure you're calling `curl.exe` – Maximilian Burszley Sep 14 '18 at 18:00
  • Sorry for the dumb question, but how can I check that? I typed `Get-Alias curl` and it just confirmed the `Invoke-WebRequest`. Also tried to put `curl.exe` directly but got an error... – Petter_M Sep 14 '18 at 18:05
  • 1
    Post your error when you're trying to use `curl.exe`. If I had to guess, you didn't qualify the path (i.e., you need to be in the directory where the executable is and call it like: `.\curl.exe ...`) – Maximilian Burszley Sep 14 '18 at 18:07
  • Nice! The error that I got now is `curl: (6) Could not resolve host: cglcloud.jfrog.io`, but I think it's because I am behind a corporate proxy. Should I set the proxy in the same `.\curl.exe` line, correct? – Petter_M Sep 14 '18 at 18:26
  • 1
    I'm unsure how to use `curl.exe` and proxies, but I'm sure if you read the manpage for the utility then you can figure out which flags to pass. – Maximilian Burszley Sep 14 '18 at 18:27
  • No problem. I am going to checking on the curl website now... – Petter_M Sep 14 '18 at 18:28
  • It seems it worked, the only issue is the `protocol error`, as follows: `curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol`. I'll take a look into it... – Petter_M Sep 14 '18 at 18:41

0 Answers0