Title: pwsh.exe writes error messages to stdout when only stdout is redirected · Issue #26675 · PowerShell/PowerShell · GitHub
Open Graph Title: pwsh.exe writes error messages to stdout when only stdout is redirected · Issue #26675 · PowerShell/PowerShell
X Title: pwsh.exe writes error messages to stdout when only stdout is redirected · Issue #26675 · PowerShell/PowerShell
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 reprodu...
Open Graph 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 PowerSh...
X 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 PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/26675
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pwsh.exe writes error messages to stdout when only stdout is redirected","articleBody":"### Prerequisites\n\n- [x] Write a descriptive title.\n- [x] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [x] Search the existing issues.\n- [x] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [x] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nExecute these commands in cmd.exe:\n```\n1\u003eoutfile pwsh.exe -Command \"Write-Error TEST\"\ntype outfile\n```\n\n\n### Expected behavior\n\n```console\nC:\\temp\u003e1\u003eoutfile pwsh.exe -Command \"Write-Error TEST\"\nWrite-Error: TEST\n\nC:\\temp\u003etype outfile\n\nC:\\temp\u003e\n```\n\n### Actual behavior\n\n```console\nC:\\temp\u003e1\u003eoutfile pwsh.exe -Command \"Write-Error TEST\"\n\nC:\\temp\u003etype outfile\nWrite-Error: TEST\n\nC:\\temp\u003e\n```\n\n### Error details\n\n```console\n\n```\n\n### Environment data\n\n```powershell\nName Value\n---- -----\nPSVersion 7.5.4\nPSEdition Core\nGitCommitId 7.5.4\nOS Microsoft Windows 10.0.19044\nPlatform Win32NT\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\nPSRemotingProtocolVersion 2.3\nSerializationVersion 1.1.0.1\nWSManStackVersion 3.0\n```\n\n### Visuals\n\nI'm executing pwsh in a cmd.exe console. When stdout is redirected to a file but stderr is not redirected, pwsh writes error messages to the file, while it should print the error in the cmd window. \nWhen stdout and stderr are both redirected or neither redirected, the behavior seems correct.\n\n```\nC:\\temp\u003epwsh.exe -Command \"Write-Error TEST\"\nWrite-Error: TEST \u003c= This line is red in color\n\nC:\\temp\u003e1\u003eoutfile pwsh.exe -Command \"Write-Error TEST\"\n\nC:\\temp\u003etype outfile\nWrite-Error: TEST \u003c= This line is red in color\n\nC:\\temp\u003e1\u003eoutfile 2\u003eerrfile pwsh.exe -Command \"Write-Error TEST\"\n\nC:\\temp\u003etype outfile\n\nC:\\temp\u003etype errfile\nWrite-Error: TEST \u003c= This line is red in color\n\nC:\\temp\u003e\n```","author":{"url":"https://github.com/zwhfly","@type":"Person","name":"zwhfly"},"datePublished":"2026-01-09T10:18:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/26675/PowerShell/issues/26675"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eba4f36a-0774-50a4-8f03-aa7880e2591f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EC48:36CCCB:455EC1:5AF51D:696472D4 |
| html-safe-nonce | f4d6e47f8cd4c87b64c94953a4924a125d3fab80062202c85cd4bba22f54ef60 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzQ4OjM2Q0NDQjo0NTVFQzE6NUFGNTFEOjY5NjQ3MkQ0IiwidmlzaXRvcl9pZCI6Ijg5ODc2MTgwMDY2ODU0Nzk2MzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f6d62cf7d351743d4d2d96e55ff6f7d56246a1763508beb086c5d705e7c86cf7 |
| hovercard-subject-tag | issue:3796376650 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/26675/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0445d4783267a95ff6e31371f3365029517bc183dcbd1e07c9181b39e3ce336d/PowerShell/PowerShell/issues/26675 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0445d4783267a95ff6e31371f3365029517bc183dcbd1e07c9181b39e3ce336d/PowerShell/PowerShell/issues/26675 |
| og:image:alt | 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 PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zwhfly |
| hostname | github.com |
| expected-hostname | github.com |
| None | baa7d9900fdf7b27d604f36887af878d569cfbdcf97126832a5f4f0caf0c6ba5 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 842eff1d11f899d02b6b3b98fa3ea4860e64b34e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width