I am using a PowerShell session to run some commands and want the argument to be passed as is, including quotes like ". The command I'm passing does not include the quotes, here is the code:
$myarg= "run"
$CArg = "XXX" ## CArg should be passed as "XXX"
Invoke-Command -Session $session -Scriptblock { param($myarg,$CArg) &'C:\program.exe' $myarg -CArg $CArg -ArgumentList $myarg,$CArg
I also tried @ArgumentList and had the same issue