我正在尝试在 PowerShell 中将日志文件输出到磁盘,但我得到了错误的文件内容。
信息如下:
Windows 10 企业版 LTSC 21H2
PowerShell 版本:
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
默认编码:
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
场景:
adb logcat WeatherActivity:D *:S > weather.log
当我在 git bash 或 mobaxterm 中做同样的事情时,它会得到像这样的正确内容。
我尝试过的: 将 PowerShell 版本从 5.1 更改为 7.3.6
PowerShell 7默认使用UTF-8输出文件,所以可能不是这个原因?
我读过的相关工作:
我期待 PowerShell 给出正确的输出文件。