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。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下