Writes an error object and sends it to the pipeline.
Snap-In: Microsoft.PowerShell.Utility
Syntax:
Write-Error
[-Message] <String> [-Category <ErrorCategory>] [-ErrorId <String>] [-TargetObject <Object>] [-RecommendedAction <String>] [-CategoryActivity <String>] [-CategoryReason <String>] [ -CategoryTargetName <String>] [-CategoryTargetType <String>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]
Write-Error -Exception <Exception>
[-Message <String>] [-Category <ErrorCategory>] [-ErrorId <String>] [-TargetObject <Object>] [-RecommendedAction <String>] [-CategoryActivity <String>] [-CategoryReason <String>] [-CategoryTargetName <String>] [-CategoryTargetType <String>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]
Write-Error -ErrorRecord <ErrorRecord>
[-RecommendedAction <String>] [-CategoryActivity <String>] [-CategoryReason <String>] [-CategoryTargetName <String>] [-CategoryTargetType <String>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]
Description:
The write-error Cmdlet is one that is used in scripts and routines. It allows you to write error messages and include other information such as Id, object data, and suggested actions.