EvotecIT/PSWriteColor

Output is multiple line in transcript

fabricesemti80 opened this issue · 2 comments

Hi !

This module is amazing and I use it in a few of my recent scripts.
I have one question though (not a huge problem I suppose):

When I use this within a script...
image

...the console output is as intended...
image

...but if the script is transcripted, the transcript results in line breaks for each color.
image

Is there any way to add a switch that prevents this?

This behavior is by design for a simple reason. Write-Color is a wrapper against Write-Host. This means for every new color on same line Write-Host is used.

For example:

Write-Host -Object 'Test' -ForegroundColor Red -NoNewline
Write-Host -Object ' test2' -ForegroundColor Yellow

This will give you same thing as Write-Color -Text 'Test',' test2' -Color Red, Yellow.

What you can do is use built-in transcript functionality into write-color Write-Color -LogFile YourPath -Color -... this will mean it will display stuff as it would and save the same line (without colors) to text file.

That is great, thanks. Overlooked that parameter somehow.