I suppose my question is somewhat similar to this: http://stackoverflow.com/questions/2607865/redirecting-the-standard-output-input-error-into-from-a-textbox but it is powershell-centric.
I'm working on an GUI created using PrimalForms that will act as a frontend to my website deployment scripts. Up until now, I've been using start-transcript and stop-transcript to update my textbox in the gui which acts as a console to view the events of the script process.
However, I'm now intending on using a script for our load balancer which is more time-sensitive. I need the text-box to be able to show the output (which is directed to write-host by said script) in real-time or close to it. Capturing a logfile/transcript after the fact simply won't do.
I've been reading up on 'Understanding Output' and all the articles I can find, but I'm not seeing a method that will really work for my needs. I was hoping there was simply a 'set-host' commandlet I could use and direct all my write-host entries to it.
Any ideas?
Edit: I've considered piping to a textfile with out-string and periodically updating from that, but it seems like a real kludge.
Edit2: hmm, maybe Tee-object... http://stackoverflow.com/questions/3463211/powershell-how-to-capture-output-from-the-host
Edit3: Okay, I'm almost there with:
ping -n 10 127.0.0.1 | out-string -Stream | foreach-object {$richTextBox1.lines = $richTextBox1.lines + $_}
but it seems to hang rather than stream.