Cmdlet.WriteObject Method (Object)
Writes a single object to the output pipeline.


Namespace: System.Management.Automation
Assembly: System.Management.Automation (in system.management.automation.dll)
Usage

Dim instance As Cmdlet
Dim sendToPipeline As Object

instance.WriteObject(sendToPipeline)
Syntax

Visual Basic
Public Sub WriteObject ( _
    sendToPipeline As Object _
)
C#
public void WriteObject (
    Object sendToPipeline
)
C++
public:
void WriteObject (
    Object^ sendToPipeline
)
J#
public void WriteObject (
    Object sendToPipeline
)
JScript
public function WriteObject (
    sendToPipeline : Object
)

Parameters

sendToPipeline

The object to be written to the output pipeline.

Exceptions

Exception typeCondition
PipelineStoppedException

The pipeline is stopped. The pipeline was terminated either before the call was made or while the call was in progress. By default, the cmdlet should allow the caller of the processing record method to catch this exception.

InvalidOperationException

The call cannot be completed at this time or cannot be completed from this thread. For more information, see the following Remarks section.

Remarks

This method can be called only from within the implementation of an input processing method (BeginProcessing, ProcessRecord, and EndProcessing) and only from that thread. If the call is made from outside these implementations or from another thread, an InvalidOperationException exception is thrown.

This method sends a single object to the pipeline, regardless of whether the object is or is not a collection. To send a collection that is then enumerated by Windows PowerShell, see the Cmdlet.WriteObject(Object,Boolean) method.

Cmdlets can also write to the debug, error, progress, warning, and verbose data streams by using the following methods:

For more information about cmdlets, see Windows PowerShell Cmdlets.


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Development Platforms

Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP, Windows 7, Windows 2008 R2

Target Platforms

Windows Server 2008, Windows Server 2003, Windows Vista, Windows XP, Windows 7, Windows 2008 R2
See Also

Page view tracker