I have a command-line executable that prints colored text to standard out. When I do the following...
my_executable.exe | Out-Host
...I find that Out-Host removes all colored output. This is a problem when I want to display the colored output of the program without sending it through the pipeline.
Is there another way that allows me to display the colored output of console programs/batch files without sending it through the pipeline?
EDIT:
In other words, what I want is this:
But Out-Host causes this:
EDIT 2:
Here's why I can't just call my_executable.exe:
I have a script in a .ps1 file similar to the following
param($someValue)
# do some things
.\my_executable.exe | Out-Host
# do some more things
return 1
Now when I do the following:
$result = .\my-script.ps1
$result is 1. If I don't use Out-Host, $result will be the output of my_executable.exe with a 1 at the end. Out-Host allows me to display the output of my_executable.exe without returning it to the caller. What I want is a way to display the colored output of my_executable.exe without returning it to the caller.
$exe = ".\my_executable.exe"
$args = ""
$process = Start-Process $exe $args -NoNewWindow -Wait -ErrorAction Stop -PassThru
if ($process.ExitCode -ne 0) {
throw "FAILED: $exe $args"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With