【发布时间】:2021-12-18 17:35:38
【问题描述】:
默认情况下,out-file 记录流 1 还是流 6?
如果我有命令:
invoke-expression $cmd *>&1 |
out-file -encoding ASCII -Append FilePath $log
out-file 将哪些流记录到文件中?
1 Success stream PowerShell 2.0 Write-Output
2 Error stream PowerShell 2.0 Write-Error
3 Warning stream PowerShell 3.0 Write-Warning
4 Verbose stream PowerShell 3.0 Write-Verbose
5 Debug stream PowerShell 3.0 Write-Debug
6 Information stream PowerShell 5.0 Write-Information
只是流 1 吗?还是流 6?我有点困惑,因为大多数 shell 只有 1 和 2,而 powershell 添加了 6,就像 1?
【问题讨论】:
-
只有流 1 被传送到
Out-File,但由于您已将流 2 到 6 的内容合并到上游流 1,Invoke-Expression输出的所有 6 个流的内容将结束正在写入磁盘