【发布时间】:2017-05-12 16:43:30
【问题描述】:
我有以下问题:
脚本没有在我的 export.txt 文件中写入任何内容,但它确实显示“找到文件!”...
$client = "my-workstation"
$file = "c$\Windows\System32\notepad.exe"
$export = "C:\temp\export.txt"
If(Test-Path "\\$client\$file")
{
write-host $client | Out-File $export
write-host "File found!"
}
【问题讨论】:
-
write-host 不返回任何内容,因此没有任何内容写入文件。
-
如果您想在控制台上查看输出并将其写入文件中,您可以使用 tee-object cmdlet。
标签: windows powershell