Skip to content

Formatting passthru fails in conhost & possibly other hosts until an Error has been returned #28452

Open

Description

@kilasuit

Prerequisites

Steps to reproduce

FYI - I have a workaround for this 🎉 - but still digging into the why this actually happens

I've narrowed this down from where I had seen this whilst building PowerShell running in conhost.

This doesn't replicate in Windows Terminal, haven't tried this in other hosts.

Repro 1 - Pipeline to Write-Verbose in Start-ResGen in build.psm1

This was via running Start-PSBuild, which calls Start-ResGen and this calls Start-NativeExecution which calls dotnet run and pipes to Write-Verbose

Note Changing to Write-Debug also shows

PowerShell/build.psm1

Lines 3265 to 3286 in c839d89

function Start-ResGen
{
<#
.SYNOPSIS
Regenerates C# resource bindings from resx files.
.DESCRIPTION
Runs the ResGen .NET tool in src/ResGen to produce strongly-typed resource classes
for all resx files in the PowerShell project.
#>
[CmdletBinding()]
param()
# Add .NET CLI tools to PATH
Find-Dotnet
Push-Location "$PSScriptRoot/src/ResGen"
try {
Start-NativeExecution { dotnet run } | Write-Verbose
} finally {
Pop-Location
}
}

Repro 2

cmd /c echo hello | Write-Verbose -Verbose
cmd /c echo hello | Write-Debug -Debug -warn # literally anything that forces error formatting
cmd /c echo hello | Write-Debug -Debug

Repro 3 - Console.WriteLine in console app

Create a console app that does this

using System;
using System.Management.Automation;

class Program
{
    static void Main()
    {
            Console.WriteLine("SomeTextThatShouldShowUpInTheOutput");
    }
}

Build that and then call it like so

. C:\ps\PS-dll-consoleApp\ConsoleToVerbose\bin\Debug\net11.0\ConsoleToVerbose.exe) | Write-Verbose -Verbose

Expected behavior

Proper wrapping & display of formatting like is done elsewhere

Actual behavior

It doesn't wrap properly

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.6.10
PSEdition                      Core
GitCommitId                    7.6.10
OS                             Microsoft Windows 10.0.26300
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Start-PSBuild -Output "$pwd-out-ParamSets" -Restore -PSModuleRestore -UseNuGetOrg -Detailed -Clean -Verbose

image

As above but comment out | Write-Verbose in Start-ResGen from build.psm1 in try {Start-NativeExecution { dotnet run } | Write-Verbose }

image

As above but change | Write-Verbose in Start-ResGen from build.psm1 to | Write-Debug

image

Same but instead of calling Start-NativeExecution wrap (dotnet run) | Write-Verbose

image

Confirmed with wrapped console app

image

Workaround

Wrap calls to executables that use Standard Output & you want this expressed in another stream like so

(. C:\ps\PS-dll-consoleApp\ConsoleToVerbose\bin\Debug\net11.0\ConsoleToVerbose.exe) | Write-Verbose -Verbose
image

Activity

  1. added
    Needs-Triage
    on Nov 18, 2026
  2. added
    Needs-Investigation
    and removed
    Needs-Triage
    on Nov 18, 2026
  3. mklement0 commented on Nov 19, 2026

    @mklement0
    Contributor

    This is a long-standing problem first reported in 2022:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Needs-Investigation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions