假设我有以下内容
$csvfiles | ForEach-Object {Import-Csv "$csvLocation\$_"; Remove-Item "$csvLocation\$_" -Verbose | tee .\log.txt -Append} |
Export-Csv -NoTypeInformation "$csvLocation\$DBName.csv" -force
我可以在控制台上看到详细的输出,但是tee没有在日志文件中附加任何内容。如何准备-verbose输出到文件? (详细信息:正在执行文件删除操作...)
答案 0 :(得分:0)
这可以解决问题
Remove-Item "$csvLocation\$DBName.csv" -ErrorAction SilentlyContinue
$csvfiles | ForEach-Object {
Import-Csv "$csvLocation\$_" | Export-Csv -Append -NoTypeInformation "$csvLocation\$DBName.csv" -Force;
Remove-Item "$csvLocation\$_" -Verbose 4>&1 | tee .\log.txt -Append
}