有没有办法在使用tee-object时阻止PowerShell删除控制台消息颜色?
当我不使用tee-object运行时,我可以获得像这样的漂亮错误和详细的PowerShell消息颜色:
powershell.exe -noprofile -file $project_root/test_main.ps1
然而,当我使用tee-object(因为我想要将日志记录到控制台和文件中)时,消息颜色未显示在控制台上(我知道文件不会显示它),如下所示:
powershell.exe -noprofile -file $project_root/test_main.ps1 | tee-object -FilePath $log
如果PowerShell只是使用tee-object将输出分到文件和控制台,为什么我会失去控制台格式?
... -command "&{ $path\test_main.ps1 | tee-object $log }"
。 - Keith Hill