[英]Why Write-Host results are sent to file?
I read everywhere (ie Redirect Write-Host statements to file ) that Write-Host
cannot be redirected to file. 我到处都读到(例如, 将Write-Host语句重定向到file )无法将
Write-Host
重定向到file。 But 但
Given t.ps1
file: 给定
t.ps1
文件:
function Log(){
Write-Host "host msg"
}
Log
I see "host msg" in file: 我在文件中看到“主机消息”:
PS D:\> & ./t.ps1 *>> .\out.log
PS D:\> gc .\out.log
host msg
我猜您可以使用Write-output而不是write-host来将输出重定向到文件或使用管道和out-file cmdlet。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.