Delen via


Cmdlet.WriteError(ErrorRecord) Method

Definition

Internal variant: Writes the specified error to the error pipe.

public:
 void WriteError(System::Management::Automation::ErrorRecord ^ errorRecord);
public void WriteError (System.Management.Automation.ErrorRecord errorRecord);
member this.WriteError : System.Management.Automation.ErrorRecord -> unit
Public Sub WriteError (errorRecord As ErrorRecord)

Parameters

errorRecord
ErrorRecord

Error.

Exceptions

Not permitted at this time or from this thread

The pipeline has already been terminated, or was terminated during the execution of this method. The Cmdlet should generally just allow PipelineStoppedException to percolate up to the caller of ProcessRecord etc.

Remarks

Do not call WriteError(e.ErrorRecord). The ErrorRecord contained in the ErrorRecord property of an exception which implements IContainsErrorRecord should not be passed directly to WriteError, since it contains a ParentContainsErrorRecordException rather than the real exception.

Applies to