Output Data in Color

by Mar 23, 2011

When you pipe results to Write-Host to output them in color, you may be in for a surprise:

Get-Process | Write-Host -ForegroundColor Yellow

The result is colorized, but Write-Host has converted the processes into very simplistic string representations. You can convert objects to string manually with Out-String to use the same rich conversion you normally see in the console:


Get-Process | Out-String -Stream | Write-Host -ForegroundColor Yellow


Twitter This Tip!
ReTweet this Tip!