title: Redirect output of another PowerShell script to a TextBox on the fly
body: <p>Hi I have a ps script that displays a GUI using WPF with a <code>[System.Windows.Controls.TextBox]</code>. On the GUI I will call some other ps scripts by clicking on various buttons and so I would like to redirect their outputs to the TextBox on the fly.</p>
  
  <p>There are two things I could not get it to work:</p>
  
  <p>First I tried this with cmdlets to update the Text property of the TextBox, which worked, but only after the cmdlet finished. So I need a way to update the Text on the fly.</p>
  
  <p>Next is I tried the same with calling other ps scripts, unlike the cmdlets, I could not capture their outputs, even after they finished. I am guessing because these scripts are using <code>Write-Host</code> instead of <code>Write-Output</code>? Otherwise, I also need a way to capture the outputs of ps scripts to update the Text on the fly.</p>
  
  <p>I am also thinking it would be much easier if there is a PowerShell cmd control that I can add to the GUI, so I don't have to do the above to achieve what I want. This control can execute the ps scripts and print the outputs there, better yet, read the user interactive input. Will pick this as the answer if this is possible.</p>