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.
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
Output a message:
PS C:\> Write-output "Hello World 123"
Output a message & variable value:
PS C:\> Write-Information $("message" + $variable)
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
Running a function will display the text:
PS C:\> Function Test-function { Write-output "here is some text" }
PS C:\> Test-function
here is some text
But if we run the function, assigning the output to a variable, nothing displays on the terminal:
$result = Test-function
"We attract hearts by the qualities we display; we retain them by the qualities we possess" ~ Jean Baptiste Antoine Suard
[Console]::WriteLine("Hello world")
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-Information - Write to the information data stream (6).
Write-Progress - Display a progress bar.
Write-Verbose - Write a string to the host’s verbose display.
Write-Warning - Write a warning message.