PSStyle means objects rendered in write-verbose look like normal output.
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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[0m <== Note ansi rending bug with $psversionTable | clip
---- -----[0m
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
#16634 was a user thinking PowerShell’s
ls
alias would output text like unix ls. So when he sent it toselect-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 headersget-itemproperty
has it on every line.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”.
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.