Contact Info

Crumbtrail » Administration » Powershell » Powershell 3.0 » Write-Error

Write-Error - Powershell 3.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »


Short description
Writes an object to the error stream.

Write-Error [-Message] <String> [-Category <ErrorCategory>] [-CategoryActivity <String>] [-CategoryReason <String>] [-C
ategoryTargetName <String>] [-CategoryTargetType <String>] [-ErrorId <String>] [-RecommendedAction <String>] [-TargetOb
ject <Object>] [<CommonParameters>]
Write-Error [-Category <ErrorCategory>] [-CategoryActivity <String>] [-CategoryReason <String>] [-CategoryTargetName <S
tring>] [-CategoryTargetType <String>] [-ErrorId <String>] [-Message <String>] [-RecommendedAction <String>] [-TargetOb
ject <Object>] -Exception <Exception> [<CommonParameters>]
Write-Error [-CategoryActivity <String>] [-CategoryReason <String>] [-CategoryTargetName <String>] [-CategoryTargetType
 <String>] [-RecommendedAction <String>] -ErrorRecord <ErrorRecord> [<CommonParameters>]

The Write-Error cmdlet declares a non-terminating error. By default, errors are sent in the error stream to the host pr
ogram to be displayed, along with output.

To write a non-terminating error, enter an error message string, an ErrorRecord object, or an Exception object.  Use th
e other parameters of Write-Error to populate the error record.

Non-terminating errors write an error to the error stream, but they do not stop command processing. If a non-terminatin
g error is declared on one item in a collection of input items, the command continues to process the other items in the

To declare a terminating error, use the Throw keyword. For more information, see about_Throw (