18 July 2013

Different colors on the same line

In order to have different font colors or different background colors in your console output you can use Write-Host cmdlet with the -NoNewline parameter:


Write-Host '1' -ForegroundColor Red -NoNewline
Write-Host '2' -ForegroundColor Green -NoNewline
Write-Host '3' -ForegroundColor Yellow -NoNewline


will output:

123

No comments:

Post a Comment