Showing posts with label Curl. Show all posts
Showing posts with label Curl. Show all posts

Tuesday, August 7, 2012

Powershell and special characters

For all those that are writing powershell scripts. I came across a unique scenario where I had to call an external application - in this scenario curl - and had to pass certain details to the application via a powershell script.

The character is a simple :

(Note: for all those wondering why I don't use build in powershell commands for downloading files from the internet, this scenario is to upload specific files to a HTTP site where a username and password is required)

Curl requires that username and password are submitted like this

<username>:<password>

Unfortunately, this caused problems with the powershell script where it would only read the username and not the password. After trying all sorts of solutions, such as ' " / \ [] {} before the : I finally found the solution!

The solution was to place the : in ' '

example: curl.exe -v --user gtlg':'randompassword --data-binary @filename https://somesite.com