title: run powershell script with C# System.Diagnostics.Process , powershell script sees no arguments
body: <p>I decided to use System.Diagnostics.Process to run a powershell script just because it seemed simple,I didn't care about the result output, and I wanted the user to be able to see what was running</p>
  
  <pre><code>Process process = new Process();
  
  Process.StartInfo.FileName = "powershell.exe"
  Process.StartInfo.Arguments = String.Format("-executionpolicy unrestricted -noexit \"{0}\" -XmlConfigFile {1}",scriptname, configFile);
  process.Start();
  </code></pre>
  
  <p>When I run this the script sees no arguments. Due to the noexit I can test $args and $MyInvocation at the end. No arguments. If I run it in cmd.exe it works, If I leave off the {1} it complains about -XmlConfigFile missing an argument.</p>
  
  <p>edit: turns out It was my fault I was running nested powershell sessions to deal with forcing powershell to use 4.0 and only passing along args which doesn't include arguments in $psboundparameters.</p>