Write-Error¶
Writes an error message to the error stream, logged according to the log level and log path configured as part of the PsLogLite
module.
Write-Error
[-Message] <String>
[-Category <ErrorCategory>]
[-ErrorId <String>]
[-TargetObject <Object>]
[-RecommendedAction <String>]
[-CategoryActivity <String>]
[-CategoryReason <String>]
[-CategoryTargetName <String>]
[-CategoryTargetType <String>]
[<CommonParameters>]
Write-Error
-Exception <Exception>
[-Message <String>]
[-Category <ErrorCategory>]
[-ErrorId <String>]
[-TargetObject <Object>]
[-RecommendedAction <String>]
[-CategoryActivity <String>]
[-CategoryReason <String>]
[-CategoryTargetName <String>]
[-CategoryTargetType <String>]
[<CommonParameters>]
Write-Error
-ErrorRecord <ErrorRecord>
[-RecommendedAction <String>]
[-CategoryActivity <String>]
[-CategoryReason <String>]
[-CategoryTargetName <String>]
[-CategoryTargetType <String>]
[<CommonParameters>]
Description¶
Info
This function is a proxy function for the Write-Error cmdlet distributed as part of the Microsoft.PowerShell.Utility built-in module. Please refer to Microsoft's documentation for how and where to use this function.
This function uses the same parameters, accepts the same inputs, and produces the same outputs as the cmdlet Write-Error
by implicitly calling a runtime-generated copy of that cmdlet within a wrapper function.
Inside that wrapper, the function sends the content of the -ErrorRecord
, -Exception
, or -Message
parameter (depending on which parameter set is used) to the central log processor, Write-Log
, a private function which decides whether the message gets logged based on the current log level, as well as where the log gets written based on the current log file path.