title: Windows Process Fails with ExitCode = -1073741819 when Executing PS Script
body: <p>I have a PowerShell script which executes some logic. If I run that script using PowerShell ISE, code works fine and no error is generated. If I run the same code using SSIS which creates Windows Process which calls that same script, under same credentials, it fails with an exit code -1073741819 and without any error from the process (p.StandardError is empty - check the code below).</p>
  
  <p>Sample code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>p = new Process();
  p.StartInfo.CreateNoWindow = true;
  p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  p.StartInfo.RedirectStandardError = true;
  p.StartInfo.RedirectStandardOutput = true;
  p.StartInfo.UseShellExecute = false;
  p.StartInfo.FileName = &lt;path_to_powershell.exe&gt;;
  p.StartInfo.Arguments = $"-NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File \"&lt;powershell_script_path&gt;\"";
  
  p.Start();
  
  string stderr = p.StandardError.ReadToEnd();
  string stdout = p.StandardOutput.ReadToEnd();
  
  var processExited = p.WaitForExit(10800000);
  
  int succ = (p.ExitCode != 0 || stderr.Length &gt; 0 || !processExited) ? 0 : 1;
  
  // Here it fails because p.ExitCode is not 0 but -1073741819
  </code></pre>
  
  <p>This same code works fine for several other scripts, but it fails for this one script for some reason. As I explained earlier, if I run this same script manually, it works fine.</p>