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

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)
'Usage
Dim instance As Cmdlet
Dim errorRecord As ErrorRecord

instance.WriteError(errorRecord)
public void WriteError (
	ErrorRecord errorRecord
)
public void WriteError (
	ErrorRecord errorRecord
)
public function WriteError (
	errorRecord : ErrorRecord
)

Parameters

errorRecord

An ErrorRecord object that describes the error condition.

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.

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

Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.