Hi I have a ps script that displays a GUI using WPF with a [System.Windows.Controls.TextBox]. 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.
There are two things I could not get it to work:
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.
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 Write-Host instead of Write-Output? Otherwise, I also need a way to capture the outputs of ps scripts to update the Text on the fly.
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.