I have to convert a UNIX Shell script to a powershell script. This script runs a conversion on ImageMagick. When I try to execute the following code:
$convertcmd="convert $dir\tmpI.mpc `(-clone 0 $process `)`(-clone 0 -channel $color2 -separate -threshold $high% $tapering `) -compose over -composite `"$outfile`"" Invoke-Expression -Command $convertcmd I keep getting
Invoke-Expression : Missing expression after unary operator '-'. At C:\test\xxxxx.ps1:189 char:21 + Invoke-Expression <<<< -Command $convertcmd + CategoryInfo : ParserError: (-:String) [Invoke-Expression], ParseException + FullyQualifiedErrorId : MissingExpressionAfterOperator,Microsoft.PowerShell.Commands.InvokeExpressionCommand The resulting string that $convertcmd becomes
convert .\COLORBALANCE\tmpI.mpc (-clone 0 -channel blue -level 0x98% +channel)(-clone 0 -channel blue -separate -threshold 18.9338% ) -compose over -composite /imagemagick/workarea/out/after.jpg I suspect its the parens as intellisense in PowerGUI gives me the same error on the (-clone... part of the statement. I've tried looking up how to escape parens, and backslashes (similar to the Unix Shell code) aren't working, neither are ` characters.