Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Write-Output

Write-Output

microsoft.powershell.commands.utility.dll

Synopsis

Sends the specified objects to the next command in the pipeline. If the command is the last command in the pipeline, the objects are displayed in the console.

Syntax

Write-Output [-InputObject] [-NoEnumerate] [<CommonParameters>]

Detailed Description

The Write-Output cmdlet sends the specified object down the pipeline to the next command. If the command is the last command in the pipeline, the object is displayed in the console.

Write-Output sends objects down the primary pipeline, also known as the "output stream" or the "success pipeline." To send error objects down the error pipeline, use Write-Error.

This cmdlet is typically used in scripts 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 the cmdlet. For example, "get-process | write-output" is equivalent to "get-process".

Parameters

-InputObject <PSObject[]>

Specifies the objects to send down the pipeline. Enter a variable that contains the objects, or type a command or expression that gets the objects.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-NoEnumerate <SwitchParameter>

By default, the Write-Output cmdlet always enumerates its output. The NoEnumerate parameter suppresses the default behavior, and prevents Write-Output from enumerating output. The NoEnumerate parameter has no effect on collections that were created by wrapping commands in parentheses, because the parentheses force enumeration.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

Input Type

System.Management.Automation.PSObject

Return Type

System.Management.Automation.PSObject

Notes

None

Examples

-------------------------- EXAMPLE 1 --------------------------

These commands get objects representing the processes running on the computer and display the objects on the console.

PS C:\>$p = get-process
PS C:\>write-output $p
PS C:\>$p

-------------------------- EXAMPLE 2 --------------------------

This command pipes the "test output" string to the Get-Member cmdlet, which displays the members of the String class, demonstrating that the string was passed along the pipeline.

PS C:\>write-output "test output" | get-member

-------------------------- EXAMPLE 3 --------------------------

This command adds the NoEnumerate parameter to treat a collection or array as a single object through the pipeline.

PS C:\>write-output @(1,2,3) | measure

Count    : 3
...

PS C:\>write-output @(1,2,3) -NoEnumerate | measure

Count    : 1

Online Version
Tee-Object
Write-Debug
Write-Error
Write-Host
Write-Progress
Write-Verbose
Write-Warning