0

I have a written a console application. Now I have a requirement to run that console application through Power-Shell script and copy the copy the console application output to a text file. I am able to access the application through Power-shell script, but unsuccessful in copying the output to the text file. I am very new to this Power-shell scripting,

My PowerShell Script so far I had written

[string]$param1
[string]$param2
[string]$exePath = "\\Visual Studio 2015\Projects\PowerShellTestApp\PowerShellTestApp\bin\Debug\PowerShellTestApp.exe"
$psi= New-Object System.Diagnostics.ProcessStartInfo $exePath
$param1 = Read-Host "Please enter your Name"
$param2 = Read-Host  "Please enter your Location"
$psi.Arguments = $param1, $param2
[System.Diagnostics.Process]::Start($psi)

1 Answer 1

1

I don't have the exact same situation to test with but you could try the last lines to be something like follows.

 $result = $([System.Diagnostics.Process]::Start($psi))
 Out-File -InputObject $result -FilePath "C:\somelocation.txt"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.