title: Invoke-Expression not passing a comma delimited list of strings to script as a single parameter
body: <p>I have a powershell script that is calling a batch script (running perl inside) which isn't parsing parameters correctly when called from my powershell script. The situation is as follows.</p>
  
  <p>When calling my batch/perl script manually</p>
  
  <pre><code>test.cmd -tasks "Task A","Task B","Task C"
  </code></pre>
  
  <p>everything works fine and the parameter "Task A","Task B","Task C" is treated as one unit that gets passed into another executable.</p>
  
  <p>But when calling using invoke-expression</p>
  
  <pre><code>$fullCommand = "cmd.exe /C C:\test\test.cmd -tasks  `"Task A`",`"Task B`",`"Task C`";
  Invoke-Expression -Command $fullCommand;
  </code></pre>
  
  <p>The batch script thinks that each string is a separate parameter. In other words, "Task A" is the first parameter after -tasks, then "Task B", then "Task C", which the script doesn't recognize how to process.</p>
  
  <p>I could get around this by passing in each task name individually (e.g. -Task "Task A" -Task "Task B" -Task "Task C"), but that would require me to have extra logic to parse these, put them into an array, then reform them into a string and pass back into another executable.</p>