Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select-String as pipeline | corrupted output #20026

Closed
5 tasks done
Ricky-Tigg opened this issue Jul 25, 2023 · 8 comments
Closed
5 tasks done

Select-String as pipeline | corrupted output #20026

Ricky-Tigg opened this issue Jul 25, 2023 · 8 comments

Comments

@Ricky-Tigg
Copy link

Prerequisites

Steps to reproduce

  1. 'tpmtool /?'or 'TPMTOOL /?'; output truncated:
> tpmtool /? 
Parameters:
 GETDEVICEINFORMATION                     Displays the basic information of the TPM. 
Examples:
 tpmtool getdeviceinformation
  1. 'tpmtool /? | Select-String -AllMatches -Pattern 'getdevice' '

Expected behavior

> tpmtool /? | Select-String -AllMatches -Pattern 'getdevice' 
 GETDEVICEINFORMATION                     Displays the basic information of the TPM. 
 tpmtool getdeviceinformation

Non-corrupted original text structure.



### Actual behavior

```console
> tpmtool /? | Select-String -AllMatches -Pattern 'getdevice'
    ←[7mGETDEVICE←[0mINFORMATION                     Displays the basic information of the TPM.
    tpmtool ←[7mgetdevice←[0minformation

Corrupted original text structure.



### Error details

_No response_

### Environment data

```powershell
> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@Ricky-Tigg Ricky-Tigg added the Needs-Triage The issue is new and needs to be triaged by a work group. label Jul 25, 2023
@237dmitry
Copy link

In my environment (win 11 22H2):

Screenshot 2023-07-25 201745

@mklement0
Copy link
Contributor

mklement0 commented Jul 25, 2023

This is a known bug, and it affects:

  • Select-String pipelines with input from native programs (simple repro: cmd /c ver | Select-String ver) whose output prints straight to the display,
  • but only on Windows, and there only in regular (conhost.exe) console windows.

See:

@Ricky-Tigg
Copy link
Author

> Get-ComputerInfo | Select WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer
WindowsProductName WindowsVersion OsHardwareAbstractionLayer                                                            ------------------ -------------- --------------------------                                                            Windows 10 Home    2009           10.0.22000.1696             
------------------ -------------- --------------------------
Windows 10 Home    2009           10.0.22000.1696
> Get-Culture
LCID             Name             DisplayName
----             ----             -----------
1035             fi-FI            Finnish (Finland)
> tpmtool /? | Select-String -AllMatches -Raw -Pattern 'getdevice'
    GETDEVICEINFORMATION                     Displays the basic information of the TPM.
    tpmtool getdeviceinformation

@237dmitry
Copy link

237dmitry commented Jul 25, 2023

and there only in regular (conhost.exe) console windows.

I do not remember when but it was. Maybe up to 7.3.6?

Screenshot 2023-07-25 213558

@mklement0
Copy link
Contributor

mklement0 commented Jul 25, 2023

@237dmitry, that only works with an opt-in (having manually set the VirtualTerminalLevel value in registry key HKEY_CURRENT_USER\Console to 1 in a previous session) - which shouldn't be necessary and indeed wasn't necessary up to v7.2.x; I've updated the linked issue to make that clearer.

@237dmitry
Copy link

that only works with an opt-in (having manually set the VirtualTerminalLevel value in registry key HKEY_CURRENT_USER\Console to 1

Yes exactly. Now I remembered. This registry value I actually set.

@Ricky-Tigg
Copy link
Author

Another issue, out of scope though; the non-reliability of Get-ComputerInfo that reports Windows 10 Home as OS while installed is Windows 11 Home, upgraded from Windows 10 Home.

@mklement0
Copy link
Contributor

mklement0 commented Jul 25, 2023

@Ricky-Tigg:

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage The issue is new and needs to be triaged by a work group. label Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants