写入主机和写入输出之间的 PowerShell 区别? [英] PowerShell difference between Write-Host and Write-Output?
本文介绍了写入主机和写入输出之间的 PowerShell 区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Write-Host 和 写入输出 在 PowerShell 中?
What is the difference between Write-Host and Write-Output in PowerShell?
喜欢...
Write-Host "Hello World ";
Write-Output "Hello World";
推荐答案
简而言之,Write-Host
写入控制台本身.将其视为 VBScript 中的 MsgBox.另一方面,Write-Output
写入管道,因此下一个命令可以接受它作为其输入.您不需要使用 Write-Output
来编写对象,因为 Write-Output
是为您隐式调用的.
In a nutshell, Write-Host
writes to the console itself. Think of it as a MsgBox in VBScript. Write-Output
, on the other hand, writes to the pipeline, so the next command can accept it as its input. You are not required to use Write-Output
in order to write objects, as Write-Output
is implicitly called for you.
PS> Get-Service
将是相同的:
PS> Get-Service | Write-Output
这篇关于写入主机和写入输出之间的 PowerShell 区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文