I'm trying to output my log file to disk in PowerShell, but i get wrong file content.
Info as follow:
Windows 10 Enterprise LTSC 21H2
PowerShell Version:
Name Value
---- -----
PSVersion 7.3.6
PSEdition Core
GitCommitId 7.3.6
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Default Encoding:
Preamble :
BodyName : utf-8
EncodingName : Unicode (UTF-8)
HeaderName : utf-8
WebName : utf-8
WindowsCodePage : 1200
IsBrowserDisplay : True
IsBrowserSave : True
IsMailNewsDisplay : True
IsMailNewsSave : True
IsSingleByte : False
EncoderFallback : System.Text.EncoderReplacementFallback
DecoderFallback : System.Text.DecoderReplacementFallback
IsReadOnly : True
CodePage : 65001
Scene:
adb logcat WeatherActivity:D *:S > weather.log
the log file outputed in powershell
When i do the same thing in git bash or mobaxterm, it get the right content like this.
the log file outputed in git bash
What i have tried: Change PowerShell version from 5.1 to 7.3.6
The PowerShell 7 use UTF-8 to out-file by default, so it may not be this reason?
Releated work i've read:
Changing PowerShell's default output encoding to UTF-8
I'm expecting PowerShell give the right output file.