Redirect all powershell console message to WDF:textbox

Need help with redirection of all output of script to textbox.

Example result from script that display in the console:

Pin-App “Word”
Pin-App “Google Chrome”
App ‘Word’ pinned to Start
App ‘Google Chrome’ pinned to Start

I want this display in the text box.

<script src=“https://gist.github.com/tuannguyen778/79b060456cd8ae51aecc18feb0087881.js”></script>

I think i found a solution to redirect all the file using write-out and >> to a file then read it in text box but it only output the result after the script finish running. Anyway to output in real time to the textbox?

  1. What do you mean by real time?
  2. Are you saying , that if you send your output to a variable, you cannot get it into the text box?
  3. Why are you popping a console for a GUI app to get data, vs just running the code and using only your GUI?
Anyway, there are many examples all over the web on how to send output to a form textbox. Two resources / with sample code are here:
https://learn-powershell.net/2012/11/09/powershell-and-wpf-textbox https://learn-powershell.net/2012/11/14/powershell-and-wpf-textblock
 

I am not popping a console for my GUI. What I am asking is the output of like Write-Host written to a textbox. My current method is using Write-Output to a file then read that file in the textbox. However that is not real time. There is no console involve.

There are a few approaches to populating a textbox, you’re running into the standard issue where while a script is running, your forms become unresponsive.
you have a few choices, background jobs is one approach, there were a number of articles on sapiens forums walking through various approaches.

https://www.sapien.com/blog/2012/05/16/powershell-studio-creating-responsive-forms/

heres the first one i could find.

in general your form will be non-responsive the entire time a block of code is executed locally.