title: Use bat to start Powershell script
body: <p>I have a batch file test.bat to start a powershell script:</p>
  
  <pre><code>@pushd "C:\myscripts"
  powershell .\test.ps1 arg1 "arg2 with space" arg3
  @popd
  </code></pre>
  
  <p>The script test.ps1 (located at C:\myscripts) is a very simple one like:</p>
  
  <pre><code># just print out the arguments
  Write-Output ("args count: {0}" -f $args.length)
  $args
  </code></pre>
  
  <p>Then I tried to start test.bat. I should get three arguments passed to ps1 but I got the following result:</p>
  
  <p>args count: 5
     arg1
     arg2
     with
     space
     arg3</p>
  
  <p>What I expected in the script, args[0] should arg1 and args[1] should be "arg2 with space" and args3[2] be arg3. I cannot understand why the script actually gets 5 arguments.</p>
  
  <p>How can I pass parameters from cmd or batch to powershell as what I expected? Like this:</p>
  
  <pre><code>args count: 3
  arg1
  arg2 with space
  arg3
  </code></pre>