-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
I have been looking around on the web and could not find a solution or a topic about it. My apologies if there is somewhere. When I use the write-error and redirect the output to a file it will result in weird symbols in the file. The other ones like write-warning or write-output work fine.
Steps to reproduce
Write-Output "Lalala" 1> C:\Temp\test.txt
Write-Error "This is a test" 2>&1 >> C:\Temp\test.txt
Write-Warning "Test Testt" 3>&1 >> C:\Temp\test.txt
Write-Information "Information Information" 6>&1 >> C:\Temp\test.txt
Expected behavior
Output in the file:
Lalala
C:\Users\MoonChild\Documents\huh.ps1 : This is a test
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,huh.ps1
Test Testt
Information Information
Actual behavior
Output in the file:
Lalala
�[91mWrite-Error: �[91mThis is a test�[0m
Test Testt
Information Information
Environment data
PSVersion 7.1.1
PSEdition Core
GitCommitId 7.1.1
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0