PowerShell 输出文件不工作
PowerShell Out-File is not working
我的以下代码行根本不会写入 Out-File
命令的文件:
Move-Item $item.Path $CaminhoCompleto -Force -WhatIf -Verbose |
Out-File -Filepath $SaidaTXT -Append -NoClobber
在屏幕上显示正确,但文件为空。
-WhatIf
消息直接写入控制台,但不能 piped or redirected without running the statement in a different PowerShell process. You can capture the output with Start-Transcript
。
Start-Transcript -Path $SaidaTXT -Append
Move-Item ...
Stop-Transcript
我的以下代码行根本不会写入 Out-File
命令的文件:
Move-Item $item.Path $CaminhoCompleto -Force -WhatIf -Verbose |
Out-File -Filepath $SaidaTXT -Append -NoClobber
在屏幕上显示正确,但文件为空。
-WhatIf
消息直接写入控制台,但不能 piped or redirected without running the statement in a different PowerShell process. You can capture the output with Start-Transcript
。
Start-Transcript -Path $SaidaTXT -Append
Move-Item ...
Stop-Transcript