title: Get ExitCode from Process in PowerShell While Redirecting StandardError
body: <p>I'm currently working on a PowerShell script that includes the line</p>
  
  <p><code>$process1 = Start-Process -FilePath ($exePath1) -PassThru -RedirectStandardError ($logPath1)</code></p>
  
  <p>Which starts a long-running process and redirects the process' StandardError to a log file. My problem is that this also apparently interferes with ExitCode.</p>
  
  <pre><code>$process1.ExitCode
  </code></pre>
  
  <p>returns null after the process has exited. If I remove "RedirectStandardError ($logPath1)" then ExitCode returns the value my dummy-program is expected to return.</p>
  
  <p>Should I be doing something different? I'm hoping to be able to start the process (redirecting the StandardError to the log file for diagnostics), wait a few seconds to make sure it doesn't crash, and retrieve the ErrorCode in the event that it does.</p>