Write an object to the pipeline. If the command is the last command in the pipeline, the objects are displayed in the console.
Syntax Write-Output [-inputObject] Object[] [CommonParameters] Key -inputObject Object The object(s) to send along the pipeline. A variable, command or expression that gets the objects. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.
Standard Aliases for Write-Output: echo, write
Write-Output writes objects to the success pipeline. To have output appear only on screen use write-host or Write-Warning instead.
If an unquoted string of characters is passed to write-output, they will be implicitly treated as a string,
so write-output hello is equivalent to:
write-output "hello"
and write-output hello world is equivalent to:
write-output "hello" "world"
Note this is not the same as
write-output "hello world"
Write-Output may be used to display strings and other objects on the console. However, because the default behavior is to display the objects at the end of a pipeline, it is generally not necessary to use Write-Output. For example, get-process | write-output is equivalent to get-process
Set the console buffer size to be extra wide:
[Console]::BufferWidth = 4096
write and echo are aliases for write-output
Examples
Write a string to the pipeline, which by default will appear on the screen:
PS C:\> $myvar="The quick brown fox"
PS C:\> write-output $myvar
"We attract hearts by the qualities we display; we retain them by the qualities we possess" ~ Jean Baptiste Antoine Suard
Related PowerShell Cmdlets:
Tee-Object - Send input objects to two places.
Write-Debug - Write a debug message to the host display.
Write-Error - Write an object to the error pipeline.
Write-Host - Display objects through the host user interface.
Write-Progress - Display a progress bar.
Write-Verbose - Write a string to the host’s verbose display.
Write-Warning - Write a warning message.