vscode-powershell: Integrated Console Colors do not work on older Windows Versions without ANSI/VTY Support (2012R2 etc.)

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

VScode with this extension have worked great for roughly a year but at some point I’m not sure of, a weird issue started happening on my dev server (Windows Server 2012 R2). ANSI characters started showing up in the integrated console.

Expected:

PS C:\Users\me> get-host

Name : ConsoleHost
Version : 7.2.1
InstanceId : fd6bb11f-cb31-4266-a524-4ff936a460bf
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

Actual:

PS C:\Users\me> get-host

[32;1mName : [0mVisual Studio Code Host
[32;1mVersion : [0m2021.10.2
[32;1mInstanceId : [0mc1c2393e-ac91-4757-826e-b9cdb6392c14
[32;1mUI : [0mSystem.Management.Automation.Internal.Host.InternalHostUserInterface
[32;1mCurrentCulture : [0men-US
[32;1mCurrentUICulture : [0men-US
[32;1mPrivateData : [0mMicrosoft.PowerShell.EditorServices.Services.PowerShellContext.EditorServicesPSHost+ConsoleColorProxy
[32;1mDebuggerEnabled : [0mTrue
[32;1mIsRunspacePushed : [0mFalse
[32;1mRunspace : [0mSystem.Management.Automation.Runspaces.LocalRunspace

Things I’ve already tried:

Google of course Un/Re install VScode Upgraded PWSH Tested the command directly in the native pwsh shell and works perfectly (seems to suggest something within the VScode integrated console)

PowerShell Version

PS D:\scripts> $psversiontable


[32;1mName                           Value[0m
[32;1m----                           -----[0m
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 6.3.9600
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


### Visual Studio Code Version

```console
PS D:\scripts> code --version

1.63.1
fe719cd3e5825bf14e14182fddeb88ee8daf044f
x64
PS D:\scripts>


### Extension Version

```console
PS D:\scripts> code --list-extensions --show-versions | Select-String powershell


ms-vscode.powershell@2021.10.2
ms-vscode.powershell-preview@2021.11.1
tobysmith568.run-in-powershell@1.1.1

PS D:\scripts>


### Steps to Reproduce

1.  Open VSCode on Windows Server 2012 R2
2.  Ensure the stable version of PowerShell is enabled with PowerShell 7.2.X installed
3.  Run a simple command like "Get-Host"

Extra info:
If I disable the "stable" version of the extension, reload, and enable the "preview" version, the ANSI characters are no longer displayed which is good. (No color though, not sure if it's supposed to or not. Also, another issue with Preview is that when a command finishes, the cursor is not visible until you hit enter on the keyboard so you're never sure if the command finished yet or not but that's another issue for Preview)

### Visuals

See the summary for a text preview

### Logs

What's weird is that when I enable "debug" logs, I do not see the issue (weird!). When I put it back to "normal" the issue happens again. I will send an email with the zipped files.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 25 (9 by maintainers)

Most upvoted comments

@ocarela Can you provide a screenshot? As noted from the bot, a new issue would be helpful if you can reproduce!

@mhdevop seeing as 2012R2 is EOL in a year and a half, I doubt a lot of engineering effort is going to go into this honestly, unless someone wants to attempt a PR, which we will facilitate.

I am going to rename the issue to be 2012 specific and flag it as “up for grabs”