Windows Dev Center

Collapse the table of content
Expand the table of content
Expand Minimize
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Cmdlet.WriteError Method

Reports a nonterminating error to the error pipeline when the cmdlet cannot process a record but can continue to process other records.

Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)

Dim instance As Cmdlet
Dim errorRecord As ErrorRecord


void WriteError (
	ErrorRecord^ errorRecord
public void WriteError (
	ErrorRecord errorRecord
public function WriteError (
	errorRecord : ErrorRecord



An ErrorRecord object that describes the error condition.

Exception typeCondition

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.


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

When this method is called, an error record is sent to the error pipeline and control is returned to the cmdlet for more processing. For more information about error reporting and error records, see Windows PowerShell Error Reporting.

This method can be called as many times as necessary, but the calls can be made only from within the cmdlet input processing methods (BeginProcessing, ProcessRecord, and EndProcessing) and only from that thread. If this call is made from outside these methods or from another thread, an InvalidOperationException exception is thrown.

This method should not be used in the following cases:

To write an object to the output pipeline, see WriteObject.

For more information about cmdlets, see Windows PowerShell Cmdlets.

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


Target Platforms

© 2015 Microsoft