Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

Write-Output

Updated: October 17, 2013

Applies To: Windows PowerShell 4.0

Write-Output

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.

Aliases

The following abbreviations are aliases for this cmdlet:

  • echo, write

Syntax

Parameter Set: Default
Write-Output [-InputObject] <PSObject[]> [-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

By default, the Write-Output cmdlet always enumerates its output. The NoEnumerate parameter suppresses the default behavior, and prevents Write-Output from enumerating output.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.Management.Automation.PSObject

    You can pipe objects to Write-Output.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Management.Automation.PSObject

    Write-Output returns the objects that are submitted as input.


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

Related topics



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.