PowerShell Select-导致 Esc 字符的字符串

PowerShell Select-String causing Esc characters

我正在尝试将一些日志合并在一起,并且 select 仅合并具有高欠载 (u:) 的行。任何超过 0 的值都很高。该代码在终端内创造奇迹。但是,当我将信息推送到文件时,我得到的是 ESC 字符而不是信息。

$Files = get-childitem C:\Tmp
$Underruns = foreach ($file in $Files) {
    $File | get-content | Select-String -Pattern ",u:[1-9].*,o:"
}
$Underruns | Out-File -Encoding utf8BOM -FilePath c:\tmp\combined.txt

上面的代码正在添加转义字符。这些字符正在阻止代码的流动。我怎样才能防止这种情况发生?

(j:0[7m,u:15424,o:[0m0)

感谢您的帮助。

经过一番挖掘,解决方案是 select-string 上的 -Raw 标志。

$Files = get-childitem C:\Tmp
$Underruns = foreach ($file in $Files) {
    $File | get-content | Select-String -Pattern ',u:[1-9].*,o:' -Raw
}
$Underruns | Out-File -Encoding utf8BOM -FilePath c:\tmp\combined2.txt