title: Preserve coloring when using Powershell's Out-Host
body: <p>I have a command-line executable that prints colored text to standard out. When I do the following...</p>
  
  <p><code>my_executable.exe | Out-Host</code></p>
  
  <p>...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.</p>
  
  <p>Is there another way that allows me to display the colored output of console programs/batch files without sending it through the pipeline?</p>
  
  <p>EDIT:</p>
  
  <p>In other words, what I want is this:</p>
  
  <p><img src="https://i.stack.imgur.com/mPmF4.png" alt="Output with coloring"></p>
  
  <p>But Out-Host causes this:</p>
  
  <p><img src="https://i.stack.imgur.com/CCCBO.png" alt="Output without coloring"></p>
  
  <p>EDIT 2:</p>
  
  <p>Here's why I can't just call my_executable.exe:</p>
  
  <p>I have a script in a .ps1 file similar to the following</p>
  
  <pre><code>param($someValue)
  
  # do some things
  .\my_executable.exe | Out-Host 
  # do some more things
  return 1
  </code></pre>
  
  <p>Now when I do the following:</p>
  
  <pre><code>$result = .\my-script.ps1
  </code></pre>
  
  <p>$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 <em>without returning it to the caller</em>. What I want is a way to display the colored output of my_executable.exe without returning it to the caller.</p>