1

I am trying to write a PowerShell script that will run a console app which is a .exe file, poll the stdout from the .exe, and depending on what get's printed to the console, will invoke a key-stroke or exit (Ctrl+C) the application. I want to be able to read the console output while the process is still running. So I don't want to wait until the process is complete.

Initially, I tried to accomplish this by creating a System.Diagnostics.Process object and calling .Start() on that process and then getting the .StandardOutput from that object. But that looks like it waits until the process is complete as I have tested the ping command.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • This answer should help: http://stackoverflow.com/a/28440479/291709 – Rynant May 03 '16 at 21:02
  • Agree. You'll need to expand the `-Action` script block for what happens when StdOut or StdErr events are detected, but otherwise that answer is the approach I'd try. – Charlie Joynt May 03 '16 at 22:48

0 Answers0