From 65b899c3a976c112e9d471fd79527e482578ae92 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 4 Aug 2025 16:31:59 -0700 Subject: [PATCH] Fix `Write-Host` to respect `OutputRendering = PlainText` (#21188) --- .../hostifaces/InternalHostUserInterface.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs index 94a25726f7..d8f2ef0bf9 100644 --- a/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs +++ b/src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs @@ -209,7 +209,14 @@ namespace System.Management.Automation.Internal.Host return; } - _externalUI.Write(foregroundColor, backgroundColor, value); + if (PSStyle.Instance.OutputRendering == OutputRendering.PlainText) + { + _externalUI.Write(value); + } + else + { + _externalUI.Write(foregroundColor, backgroundColor, value); + } } /// @@ -303,7 +310,14 @@ namespace System.Management.Automation.Internal.Host return; } - _externalUI.WriteLine(foregroundColor, backgroundColor, value); + if (PSStyle.Instance.OutputRendering == OutputRendering.PlainText) + { + _externalUI.WriteLine(value); + } + else + { + _externalUI.WriteLine(foregroundColor, backgroundColor, value); + } } ///