How to resolve the following error message?

4k views Asked by At

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'L'. At line:1 char:6

  • curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token?
  •  ~~
    
    • CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    • FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
1

There are 1 answers

0
Russ Cam On

On Windows, curl is an alias for PowerShell's Invoke-WebRequest cmdlet, which can cause issues when running curl commands in a PowerShell prompt because the arguments for curl and the arguments for Invoke-WebRequest are not the same. It's an unfortunate historical decision that is somewhat tricky to remove because there may be many scripts relying on the behaviour.

To resolve, you can either

or

  • Use Invoke-WebRequest with the equivalent arguments, which would be
Invoke-WebRequest https://www.googleapis.com/oauth2/v4/token -Method Post 

The -L command of curl is not needed for Invoke-WebRequest as it follows redirects by default (up to 5), but this can be increased with -MaximumRedirection argument.