PowerShell 写输出
示例
Write-Output产生输出。该输出可以转到管道之后的下一个命令或控制台,以便简单显示。
Cmdlet将对象沿着主管道(也称为“输出流”或“成功管道”)发送。要将错误对象发送到错误管道,请使用Write-Error。
# 1.) Output to the next Cmdlet in the pipeline
Write-Output 'My text' | Out-File -FilePath "$env:TEMP\Test.txt"
Write-Output 'Bob' | ForEach-Object {
"My name is $_"
}
# 2.) Output to the console since Write-Output is the last command in the pipeline
Write-Output 'Hello world'
# 3.) 'Write-Output' CmdLet missing, but the output is still considered to be 'Write-Output'
'Hello world'Write-Outputcmdlet将指定对象沿管道发送到下一个命令。
如果该命令是管道中的最后一个命令,则对象将显示在控制台中。
PowerShell解释器将此视为隐式的Write-Output。
由于Write-Output的默认行为是在管道的末尾显示对象,因此通常不必使用Cmdlet。例如,Get-Process|Write-Output等效于Get-Process。
热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短