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 教师闺蜜祝福语简短