9

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?

7
  • 7
    curl is a built-in alias for Invoke-WebRequest. Make sure you're calling curl.exe Commented Sep 14, 2018 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
    Commented Sep 14, 2018 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 ...) Commented Sep 14, 2018 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
    Commented Sep 14, 2018 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. Commented Sep 14, 2018 at 18:27

1 Answer 1

6

As @Maximilian Burszley wrote, curl in PowerShell is an alias to another command, not the curl command you intended.

In my opinion the simplest solution is to remove the alias, and then the curl command will be available without the overhead of Get-Alias and without using curl with the executable's path.

This is the command to remove the curl alias when using Windows PowerShell:

Remove-item alias:curl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.