EvotecIT/PSWriteColor

write-color transcript output showing up on different lines

Closed this issue · 1 comments

When using start-transcript the log files shows, write-color using multiple colors on one line on multiple lines.

Example:
Write-Color "Updating Group: ",$Group -Color Gray,Green -StartTab 1

Output:
Updating Group:
Test Group

Is there a way to fix this issue with start-transcript so one line on write-color will be one line in the transcript file?

Thank you.

No. This is by design. The colors on same line are achieved using Write-Host -NoNewLine. So basically when you have 5 colors on single line there's 5xWrite-Host -NoNewLine with proper formatting.

I would need to change how the module works by using ansi escape codes:

This is something I've been planning to dive into - and it would give you one line for sure

$fgColors = '30','31','32','33','34','35','36','37'
$bgColors = '40','41','42','43','44','45','46','47'

foreach ($fgColor in $fgColors)
{
    $bgColor = $bgColors | Get-Random
    Write-Output "`e[$($fgColor)m#PS7`e[0m`e[30;$($bgColor)m Now `e[0m`e[7;$($fgColor);$($bgColor)m >_ `e[0m"
}

But then your output line in transcript would look like mess above - would that be preferred? I am not 100% sure on that. The good news is - once achieved - a lot more options would show up.