question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PSStyle means objects rendered in write-verbose look like normal output.

See original GitHub issue

Prerequisites

Steps to reproduce

One of the advantages of the use of a different colour for write-verbose is that mixed with output the colour tells the user what is output and what is not. I find the green headings in 7.2 and 7.2.1 distracting so may profile has

    $PSStyle.Formatting.TableHeader       = $null
    $PsStyle.Formatting.FormatAccent      = $null

Under 7.2.1 a sample like this

write-verbose "about to kill some processes" -verbose ; 
Get-Process notepad | out-string | write-verbose  -Verbose

Produces the initial message in yellow, produces the column headers in yellow. Then at the end of the header line (in fact both header lines) ESC[0M is sent which turns the remaining text from yellow to white. This didn’t seem to happen in 7.2 , I noticed it after the 7.2.1 update and after getting the sample below from some live code I spent some time trying to find what had caused the script to output objects instead of sending them to verbose.

Expected behavior

All verbose output is printed in the colour selected for verbose

Actual behavior

Some isn't.

Error details

None

Environment data

Name                           Value      <==   Note ansi rending bug with $psversionTable | clip
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jhoneillcommented, Dec 16, 2021

I find the green headings in 7.2 and 7.2.1 distracting

Me too. This is a very sad situation. I don’t know how long it takes to understand why color schemes in Windows are so carefully chosen.

It is in #16634 too.

#16634 was a user thinking PowerShell’s ls alias would output text like unix ls. So when he sent it to select-string, and got a a search through the contents of all the files for the text “dll” instead of a search of the file listing (a) It was unexpected and (b) there were some really long “lines” 😃

Not sure if you mean #16618. I thought I posted to that one - maybe I was a bit forthright in my views and someone deleted it. But that one means out-of-the-box PowerShell can’t redirect to a file without getting Ansi-corruption. dir > file has it , in the headers get-itemproperty has it on every line.

AuthenticationLevelOverride : 0
PSPath                      : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Terminal Server Client\
PSParentPath                : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft
PSChildName                 : Terminal Server Client
PSDrive                     : HKCU
PSProvider                  : Microsoft.PowerShell.Core\Registry

I don’t know how long it takes to understand why color schemes in Windows are so carefully chosen.

What happens is sooner or later some dev or devs look at the monochrome text and think things would be a whole lot better if they were in colours or (heaven help us) flashing, or some such. They colour things in a way they like, but doesn’t make any sense to anyone else - take a simple example, the experimental feature in Pwsh to apply colours to file listings says compressed files should be red. Red is usually used for “Danger” “Beware”, “Not right”, so why mark zips as worrying ? Simply because the guy who did it liked red. For every person who likes the prettification, there’s another who is driven mad by it. No UI expert is ever involved. No one is able to tell them “You’ve made everyone less productive because they’re spending more time reading and trying to understand what the visual differences mean”.

0reactions
jhoneillcommented, Jul 22, 2022

The issue described in the title is fixed in the the current preview of 7.3, together with the other issues of stray ansi sequences mentioned, and the matter of other hosts has its own issue. Therefore, I’ll close this one one now.

If there will be another release of 7.2 before 7.3 is released it would be good to think about bringing these changes to 7.2, but I imagine all that would do is take effort away from getting 7.3 done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using PowerShell with $PSStyle
In this post, I show you how you can use ANSI rendering to control text decorations, such as color and font styling, in...
Read more >
about Preference Variables - PowerShell
PowerShell includes a set of variables that enable you to customize its behavior. These preference variables work like the options in ...
Read more >
Friday Fun - Painting a Pretty Picture with PowerShell
The easiest way is to use the FromRGB() method on $PSStyle. Foreground in PowerShell 7.2.
Read more >
Write-Information does not appear to work in powershell ...
1 Answer 1 · Both Write-Verbose and Write-Information are silent by default, as is Write-Debug . · You can make their output show...
Read more >
Untitled
This is because the command must be designed to write verbose output. The only way you can know which ones can is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found