Write-Output
Use Write-Output to send objects to the success stream, which is the stream the pipeline carries and a caller can capture.
Documentation: Microsoft Learn — Write-Output
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Write-Output [-InputObject] <PSObject[]> [-NoEnumerate] [<CommonParameters>]- Stage 1Write-Output
-InputObject -NoEnumerate
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Write with Write-Output
Show reference output
Sample output · fictional data, shaped like the real thing
captured
Select Count
Show reference output
Sample output · fictional data, shaped like the real thing
Count
-----
1Parameters
Parameter definitions:
-InputObject-NoEnumerate
Practical use and troubleshooting
Practical scenario: Use Write-Output when you need to send objects to the success stream, which is the stream the pipeline carries and a caller can capture. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: A function returning diagnostic text alongside objects can break callers. Keep only the intended result objects on the success stream and move narration to a diagnostic stream. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Out-Host. Out-Host sends output to the host display; Write-Output sends it along the success pipeline. Sending a result to the host prevents ordinary downstream object processing. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Put this command to work
Catch a missing service
Request MissingService with -ErrorAction Stop inside try/catch. Return Service unavailable from the catch block.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.
Inspect starting data
Supported syntax
Virtual files
Recap
Write-Output Use Write-Output to send objects to the success stream, which is the stream the pipeline carries and a caller can capture.
Next: Write-Information