Using –% in PowerShell

I had this same problem, and there is a workaround for this problem. I recently blogged about this (Use PowerShell variables after escaping parsing in PowerShell v3.0 – 2013-09-17) after taking inspiration from my own answer, Executing external command from PowerShell is not accepting a parameter.

The trick is to use --% itself as a variable and include that along with other variables in PowerShell.

So instead of this,

&"./plink.exe" --% $Hostname -l $Username -pw $Password $Command

try this:

$escapeparser="--%"
& "./plink.exe" $escapeparser $Hostname -l $Username -pw $Password $Command

It may be related, but I used single quotes in all variables.

Leave a Comment