windows - 写入主机和写入输出之间的 PowerShell 区别?

标签 windows powershell

Write-Host 之间有什么区别?和 Write-Output在 PowerShell 中?

喜欢...

Write-Host "Hello World";

Write-Output "Hello World";

最佳答案

简而言之,Write-Host 写入控制台本身。将其视为 VBScript 中的 MsgBox。 .另一方面,Write-Output 写入管道,因此下一个命令可以接受它作为输入。您不需要使用 Write-Output 来编写对象,因为 Write-Output 是为您隐式调用的。

PS> Get-Service

将等同于:

PS> Get-Service | Write-Output

关于windows - 写入主机和写入输出之间的 PowerShell 区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19754069/

相关文章:

iis - 如何运行 PowerShell 脚本 "in"IIS?

powershell - 结合powershell输出

C++ WinINET FtpPutFile 错误代码 3

windows - 当使用堆栈构建时,有没有办法在 powershell 终端上正确格式化 GHC 错误消息?

windows - CP 命令提示符 Windows 7 无法识别

windows - 批处理文件 - 如果只有一个进程正在运行,如何杀死进程?

java - Client SocketInputStream.close() 导致更多的资源消耗?

sharepoint - 将 Microsoft.SharePoint.SPList 传递给函数

c# - 从单独的线程更新 cmdlet 进度的最佳方法

Powershell 文本框 SecureString