Pages

Friday, July 1, 2016

Error while running a PowerShell script with 'curl'

This week I was working on a script to back-up a Audiocodes gateway, while running the script I got below error and it took a day of mine to troubleshooting the issue.

Invoke-WebRequest : Cannot bind parameter 'WebSession'. Cannot convert the "%{http_code}" value of type "System.String" to type "Microsoft.PowerShell.Commands.WebRequestSession".At C:\scripts\Untitled4.ps1:20 char:50+ $statuscode = curl -o null.txt $loginurl -w '%{http_code}'+ ~~~~~~~~~~~~~~+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

clip_image001

Solution which worked for me

After digging lot into the issue came to know that the issue was due to an Alias of ‘curl’

To solve the issue run "Remove-Item alias:curl" from the same PowerShell window or write curl.exe instead of writing just 'curl'

Hope this will help you Winking smile

No comments:

Post a Comment