Powershell 7.2: Debug console shows ansi color codes in output

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
abrayninger
Posts: 3
Last visit: Thu Jun 15, 2023 9:42 am

Powershell 7.2: Debug console shows ansi color codes in output

Post by abrayninger »

Product: PowerShell Studio 2022 (64 Bit)
Build: v5.8.198
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19043.0
Powershell: 7.2.1

When debugging in the PS v7 mode, the PS styling feature does not work properly and colors are shown as ansi codes which is significantly complicates the debug process. I've tried to disable the "stylish" output with the command

Code: Select all

$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText
but it does not help.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Powershell 7.2: Debug console shows ansi color codes in output

Post by Alexander Riedel »

Colors are detrimental to the debugging process, particularly as they are not designed to fit within the selected color scheme of PowerShell Studio. Specifically users with vision impairments or color blindness may be adversely affected if coloring is not carefully chosen.
As you have noticed, PowerShell 7.2.x mixes ANSI sequences into virtually any output, even in output redirected into a text file via Out-File, and ignores the pertinent settings to disable this feature.
This is a PowerShell bug we have no control over and you likely should report this to the PowerShell Team.
The only thing we could possible do, if the PowerShell team does not address this, is to filter out the escape sequences where appropriate.
Alexander Riedel
SAPIEN Technologies, Inc.
abrayninger
Posts: 3
Last visit: Thu Jun 15, 2023 9:42 am

Re: Powershell 7.2: Debug console shows ansi color codes in output

Post by abrayninger »

Could you please suggest a proper way to filter out the ansi escape codes in the debug consle?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Powershell 7.2: Debug console shows ansi color codes in output

Post by Alexander Riedel »

This is not something you can do, as the mechanism in PowerShell is broken.
We did however just release a service build that should filter them out.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 2 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.