Public/Get-ErrorDetail.ps1
function Get-ErrorDetail { param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)] $Exception ) process { if ($Exception -is [Management.Automation.ErrorRecord]) { $Result = [PSCustomObject]@{ Reason = $Exception.CategoryInfo.Reason Exception = $Exception.Exception.Message Target = $Exception.CategoryInfo.TargetName Script = $Exception.InvocationInfo.ScriptName Line = $Exception.InvocationInfo.ScriptLineNumber Column = $Exception.InvocationInfo.OffsetInLine Datum = Get-Date User = [System.Environment]::UserName } } else { $Result = 'Не удалось получить детальную информацию об ошибке.' } } end { return $Result } } |