title: PowerShell, stream Process output and errors while running external process
body: <p>I am using a PowerShell script to execute a console application and I am trying to redirect the standard output and the standard error from there.
  The code I am using is the following:</p>
  
  <pre><code>$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo 
  $ProcessInfo.FileName = "myExe.exe"
  $ProcessInfo.Arguments = "bla bla bla"
  $ProcessInfo.RedirectStandardError = $true 
  $ProcessInfo.RedirectStandardOutput = $true 
  $ProcessInfo.UseShellExecute = $false 
  $Process = New-Object System.Diagnostics.Process 
  $Process.StartInfo = $ProcessInfo 
  
  $Process.Start() | Out-Null 
  $output = $Process.StandardOutput.ReadToEnd() 
  $errors = $Process.StandardError.ReadToEnd()
  $Process.WaitForExit() 
  $output 
  $errors 
  
  return $Process.ExitCode
  </code></pre>
  
  <p>So far so good, if I have an error I can see it redirected into my PowerShell console and if I have output it is also redirected.
  The issue is that this process takes 10 minutes and in the meantime we have no clue of what is going on.</p>
  
  <p>Is there any way in PowerShell I can <strong>stream</strong> the content of the Output and the Error while the process is running? In pure .NET we can subscribe to events of the Process class, can I do the same in PowerShell?</p>