I am trying run a curl command using powershell as follows:
$command=".\curl.exe -k -X POST --data @login.txt -H ""Content-Type:application/json;charset=utf-8"" https://myserversfqdn:4443/ControlPoint/api/v1/login"
$res= Invoke-Expression $command
It gives me an error saying the splatting operator @ cannot be used to refernce variables in an expression.. so I add the a backtick before @login.txt..
$command=".\curl.exe -k -X POST --data '@login.txt -H ""Content-Type:application/json;charset=utf-8"" https://myserversfqdn:4443/ControlPoint/api/v1/login"
$res= Invoke-Expression $command
Now it gives me an error saying the expression is missing a terminator ‘ (backtick)..
I am lost as to how to I pass the @ character in this command ?? Any guidance is really appreciated
It looks more like you are using the single quote charac ter
'rather than the backtick:(Note that the backtick is usually on the same key as the ~ character.)
But you are half way to your answer, you could also wrap the whole argument in single quotes to pass it as an unparsed string: