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。
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短