Write ErrorRecord - PPOSHGROUP/PPoShTools GitHub Wiki

Write-ErrorRecord

PPoShTools -> Write-ErrorRecord.ps1

Synopsis

Logs ErrorRecord message, including script StackTrace and exception StackTrace.

Syntax

Write-ErrorRecord [[-ErrorRecord] <ErrorRecord>] [-NoThrow] [-PassThru] 
[<CommonParameters>]

Parameters

-ErrorRecord<ErrorRecord>

Error record to log. If null, $_ will be used.

  • PipelineInput: false
  • Required: false

-NoThrow<SwitchParameter> (default: False)

If specified, exception will not be thrown at the end.

  • DefaultValue: False
  • PipelineInput: false
  • Required: false

-PassThru<SwitchParameter> (default: False)

If specified, all log output will be available as return value.

  • DefaultValue: False
  • PipelineInput: false
  • Required: false

Examples

Example 1

$Global:ErrorActionPreference = 'Stop'

try { ... } catch { Write-ErrorRecord }

⚠️ **GitHub.com Fallback** ⚠️