Closed zammitt closed 4 years ago
This is because that coloring is actually applied by the host (consolehost in this case) whereas the error formatting is VT100 escape sequences embedded in the text. You can use $host.PrivateData to get the colors that would have been used.
@SteveL-MSFT Warning is still kind of inconsistent though. I'd expect that a WarningRecord
would be formatted similar to how it's stream appears. I know that's host specific, but I don't think it would necessarily be a bad idea to give it formatting similar to how ConsoleHost
emits it.
(To clarify, objects saved to WarningVariable
are actually typed as WarningRecord
instead of just a plain string)
This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.
I want to capture all data emmitted from a command to display to the user at a later time.
Using the common
-*Varaible
parameters captures everything in the correct order, however when I display them later the formatting compared to what the console originally printed is lost.Steps to reproduce
Expected behavior
Printing $buffer should match the output from Get-DataTest.
Actual behavior
Color from Write-Host and Write-Warning is lost.
Warning:
label for Write-Warning is lost. Surprisingly, the data captured from Write-Error is displaying with color and in the exact same format.Environment data