title: Powershell with Robocopy and Arguments Passing
body: <p>I'm trying to write a script that uses <code>robocopy</code>.  If I were just doing this manually, my command would be:</p>
  
  <pre><code>robocopy c:\hold\test1 c:\hold\test2 test.txt /NJH /NJS
  </code></pre>
  
  <p>BUT, when I do this from powershell, like:</p>
  
  <pre><code>$source = "C:\hold\first test"
  $destination = "C:\hold\second test"
  $robocopyOptions = " /NJH /NJS "
  $fileList = "test.txt"
  
  robocopy $source $destination $fileLIst $robocopyOptions
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>-------------------------------------------------------------------------------
     ROBOCOPY     ::     Robust File Copy for Windows
  -------------------------------------------------------------------------------
  
    Started : Fri Apr 10 09:20:03 2015
  
     Source - C:\hold\first test\
       Dest - C:\hold\second test\
  
      Files : test.txt
  
    Options : /COPY:DAT /R:1000000 /W:30
  
  ------------------------------------------------------------------------------
  
  ERROR : Invalid Parameter #4 : " /NJH /NJS "
  </code></pre>
  
  <p>However, if I change the robocopy command to </p>
  
  <pre><code>robocopy $source $destination $fileLIst  /NJH /NJS 
  </code></pre>
  
  <p>everything runs successfully.  </p>
  
  <p>So, my question is, how can I pass a string as my robocopy command options (and, in a larger sense, do the same for any given external command)</p>