Windows desktop applications
Collapse the table of content
Expand the table of content
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.

ErrorRecord Class


Updated: April 27, 2016

Applies To: Windows PowerShell

Describes a terminating or nonterminating error that occurred during the processing of a command.

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

Public Class ErrorRecord
	Implements ISerializable

System_CAPS_pubmethodErrorRecord(ErrorRecord, Exception)

Initializes a new instance of the ErrorRecord class that contains a wrapper exception that already has an error record. Introduced in Windows PowerShell 3.0.

System_CAPS_pubmethodErrorRecord(Exception, String, ErrorCategory, Object)

Initializes a new instance of the ErrorRecord class that contains the exception, error identifier, error category, and more.

System_CAPS_protmethodErrorRecord(SerializationInfo, StreamingContext)

Initializes a new instance of the ErrorRecord class that contains information read from the provided serialization information.


Gets information about the category of the error.


Gets and sets more detailed error information, such as a replacement error message.


Gets the exception that is associated with this error record.


Gets the fully qualified error identifier for this error record.


Gets information about the command that was invoked when the error occurred.


Gets the status of the pipeline when this error record was created. This property is introduced in Windows PowerShell 2.0.


Gets the script stack trace for the error. Introduced in Windows PowerShell 3.0.


Gets the object that was being processed when the error occurred.


(Inherited from Object.)


(Inherited from Object.)


(Inherited from Object.)

System_CAPS_pubmethodGetObjectData(SerializationInfo, StreamingContext)

Provides serialization functionality for the ISerializable interface.


(Inherited from Object.)


(Inherited from Object.)


Retrieves a string representation of the current ErrorRecord object.(Overrides Object.ToString().)

The ErrorRecord class is used only by the Windows PowerShell runtime. There are no established scenarios for deriving from this class. For more information about error records, see Windows PowerShell Error Records.

Error records that describe terminating errors are reported when the Cmdlet.ThrowTerminatingError method and the CmdletProvider.ThrowTerminatingError method are called.

Error records that describe nonterminating errors are reported by calling the Cmdlet.WriteError method and the CmdletProvider.WriteError method.

Error records are also used by several exceptions that are thrown by the Windows PowerShell runtime.

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

Return to top
© 2016 Microsoft