powershell v2.0 - Escaping quotes and double quotes -
i'm new powershell...and wondering how escape quotes in -param value.
$cmd="\\server\toto.exe -batch=b -param="sort1;parmtxt='security id=1234'"" invoke-expression $cmd
this of course fails, tried escape quotes (single , double) using escape character ` , did various combination nothing working. please help
escaping parameters source of frustration , feels lot time wasted. see you're on v2 suggest using technique joel "jaykul" bennet blogged while ago
long story short: wrap string @' ... '@ :
start-process \\server\toto.exe @' -batch=b -param="sort1;parmtxt='security id=1234'" '@
(mind assumed quotes needed, , things attempting escape) if want work output, may want add -nonewwindow switch.
btw: important issue since v3 can use --%
stop powershell parser doing parameters:
\\server\toto.exe --% -batch=b -param="sort1;paramtxt='security id=1234'"
... should work fine there (with same assumption).
Comments
Post a Comment