0

I have a .Net Framework Console App that prints Hexadecimal strings (base 16) whenever ENTER key is pressed.

class Program
{
    static void Main(string[] args)
    {
        int counter = 0;

        while (Console.ReadKey().Key == ConsoleKey.Enter
            && counter.ToString("X2") != "100")
        {
            Console.WriteLine("{0}", counter.ToString("X2"));
            counter++;
        }
    }
}

I am able to run and interact with this console app using a powershell script.

Add-Type -AssemblyName System.Windows.Forms

$csvProc = Start-Process C:\Users\name\source\repos\Solution\Project\bin\Debug\consoleapp.exe -PassThru

Sleep 1

do{
[System.Windows.Forms.SendKeys]::SendWait('~');

}while(!$csvProc.HasExited)

$csvProc | Stop-Process

Is there a way for powershell to get the hexadecimal strings output from the console app and save it in a text file?

0 Answers0