PowerShell / PowerShell/PowerShell
`Write-Host`'s `--*groundColor` doesn't work when inside an instance piped to another command
Open
Nobody has claimed this yet.
Needs-Triage
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
From outside powershell, run a powershell script that produces colours using Write-Host --ForegroundColor, and then pipe that output for further processing.
In the attached image I show
- coloured text can be pushed through
Write-Host, even if the output is processed - coloured text can be generated by
Write-Host --*groundColor, if not post-processed - coloured text cannot make it out from
Write-Host --*groundColor, if post-processed - same as test 1, but manual
Expected behavior
Colours are maintained.
Actual behavior
Colours are not maintained.
Error details
No response
Environment data
PSVersion 7.3.4
PSEdition Core
GitCommitId 7.3.4
OS Linux 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21)
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported behavior on PowerShell 7.3.4 on Linux using Write-Host with --ForegroundColor or --BackgroundColor inside a pipeline, then compare it with unprocessed output. The issue names no source files or tests, so trace Write-Host's color handling and pipeline serialization before determining how to verify that colours are maintained after processing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100