Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

A curl command pasted into PowerShell fails with a parameter binding error

Your error

Invoke-WebRequest : A positional parameter cannot be found that accepts argument '\'.2 more lines it can show

Fix it fast

Most common cause, 1 of 3

curl is an alias for Invoke-WebRequest in Windows PowerShell 5.1

Write curl.exe so PowerShell skips the alias and runs the curl program, which every Windows 10 and 11 installation includes; then the flags mean what the API docs say.

Fix
curl.exe --request POST --data "name=test" https://api.example.com/items

Invoke-WebRequest -Uri https://api.example.com/items -Method Post `
  -Headers @{ Authorization = 'Bearer TOKEN' } `
  -ContentType 'application/json' -Body '{"name":"test"}' -UseBasicParsing
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

A positional parameter cannot be found that accepts argument means Windows PowerShell 5.1 ran your curl command as Invoke-WebRequest, its built-in curl alias, and could not bind the leftover words. Type curl.exe to run the real curl that Windows 10 and 11 ship, join backslash-continued lines, and quote values with spaces. PowerShell 7 has no curl alias.

  • Applies to Windows PowerShell 5.1, PowerShell 7.6, PowerShell 7.7, curl.exe 8 on Windows 10 and 11
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Ask PowerShell what curl means in this session and which version you run. An alias that resolves to Invoke-WebRequest means PowerShell, not curl, is reading your flags.

Run this first
Get-Alias curl
$PSVersionTable.PSVersion
Get-Command curl.exe

Then find the line you see in this list and open its fix:

  1. 1curl is an alias for Invoke-WebRequest in Windows PowerShell 5.1Get-Alias curl shows Invoke-WebRequest, and the error line starts with Invoke-WebRequest
  2. 2A command copied from Linux docs still has backslash line breaksThe argument named in the error is '\', and the command came from a multi-line curl example
  3. 3A value with spaces is split into several argumentsThe argument named in the error is one word of your data, for example 'Smith' from name=John Smith

What does the error look like?

  • Invoke-WebRequest : A positional parameter cannot be found that accepts argument '\'.
  • A positional parameter cannot be found that accepts argument 'Smith'.
  • A parameter cannot be found that matches parameter name 'X'.

Cause 1 of 3

curl is an alias for Invoke-WebRequest in Windows PowerShell 5.1

You seeGet-Alias curl shows Invoke-WebRequest, and the error line starts with Invoke-WebRequest

Check

A positional parameter cannot be found, or a parameter cannot be found that matches name 'X', in Windows PowerShell 5.1 means the alias sent your curl flags to Invoke-WebRequest. Its 5.1 reference lists iwr, curl and wget as aliases, and only -Uri takes a value by position, so every other bare word fails to bind. The PowerShell 7 reference lists only iwr.

Check
Get-Alias curl
Get-Command curl.exe

Fix

Write curl.exe so PowerShell skips the alias and runs the curl program, which every Windows 10 and 11 installation includes; then the flags mean what the API docs say. Or use the cmdlet's own parameters. On 5.1 add -UseBasicParsing: since the December 2025 security update, Invoke-WebRequest otherwise stops at a script-execution prompt.

Fix
curl.exe --request POST --data "name=test" https://api.example.com/items

Invoke-WebRequest -Uri https://api.example.com/items -Method Post `
  -Headers @{ Authorization = 'Bearer TOKEN' } `
  -ContentType 'application/json' -Body '{"name":"test"}' -UseBasicParsing

Verify

The command returns a status code from the server instead of a binding error.

Verify
(Invoke-WebRequest -Uri https://api.example.com/health -UseBasicParsing).StatusCode

Confirmed by curl.se

Did this fix it?

Cause 2 of 3

A command copied from Linux docs still has backslash line breaks

You seeThe argument named in the error is '\', and the command came from a multi-line curl example

Check

A positional parameter cannot be found that accepts argument '\' means PowerShell received the backslashes that end each line of a Linux curl example. PowerShell does not treat the backslash as an escape or continuation character; its escape character is the backtick, which continues a command only when it is the very last character on the line.

Check
Get-Content .\request.ps1

Fix

Join the command into one line, or end each line with a backtick and nothing after it. For long calls, Microsoft recommends splatting: put the parameters in a hash table and pass it with @.

Fix
$p = @{
  Uri         = 'https://api.example.com/items'
  Method      = 'Post'
  ContentType = 'application/json'
  Body        = '{"name":"test"}'
}
Invoke-WebRequest @p -UseBasicParsing

Verify

The splatted call runs and prints the status code.

Verify
(Invoke-WebRequest @p -UseBasicParsing).StatusCode

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 3

A value with spaces is split into several arguments

You seeThe argument named in the error is one word of your data, for example 'Smith' from name=John Smith

Check

A positional parameter cannot be found that accepts argument 'Smith' means a value with a space was not quoted, so PowerShell split it into two arguments. In argument mode, values that contain spaces must be enclosed in quotes; the second word then has no parameter to bind to.

Check
# wrong: Smith becomes a separate argument
Invoke-WebRequest -Uri https://api.example.com/items -Method Post -Body name=John Smith

Fix

Quote the whole value. With Invoke-WebRequest, a hash table as -Body is sent as name=value form fields on a POST.

Fix
Invoke-WebRequest -Uri https://api.example.com/items -Method Post `
  -Body @{ name = 'John Smith'; email = 'john@example.com' } -UseBasicParsing

Verify

The server log or response shows the name John Smith in one field.

Verify
Invoke-WebRequest -Uri https://api.example.com/items -Method Post -Body @{ name = 'John Smith' } -UseBasicParsing | Select-Object StatusCode, Content

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Write curl.exe, never curl, in scripts and runbooks that Windows users will paste.
  • Turn multi-line API examples into a splatted hash table, so there is no continuation character to get wrong.
  • Run API scripts in PowerShell 7, where curl is not an alias and -UseBasicParsing has no effect.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.