ConvertFrom-ErrorRecord.ps1


Interesting stuff further down the page! 🤔


Something Exciting

Something about the lack of information and the thought about making as many scripts available as possible, regardless of any missing additional content.

Some information about the exciting thing…..that’s actually what will be here, rather than this filler text.

Please report any issues or suggestions using the link in the Report Issues section. If you report a requirement for more information, I can prioritise which pages are updated first. At present, I am working on adding information for each exciting thing contained within these pages.

Back to Top


Examples

This section will, in the near future, contain one or more examples of the script/function/etc in use and a small sample of the output and will hopefully prove somewhat more useful than the current content 🤷‍♂️

Back to Top


Script

function ConvertFrom-ErrorRecord {
    [CmdletBinding(DefaultParameterSetName = "ErrorRecord")]
    param
    (
        [Management.Automation.ErrorRecord]
        [Parameter(Mandatory,
            ValueFromPipeline,
            ParameterSetName = "ErrorRecord",
            Position = 0)]
        $Record,

        [Object]
        [Parameter(Mandatory,
            ValueFromPipeline,
            ParameterSetName = "Unknown",
            Position = 0)]
        $Alien
    )

    process {
        if ($PSCmdlet.ParameterSetName -eq 'ErrorRecord') {
            [PSCustomObject]@{
                Exception = $Record.Exception.Message
                Reason    = $Record.CategoryInfo.Reason
                Target    = $Record.CategoryInfo.TargetName
                Script    = $Record.InvocationInfo.ScriptName
                Line      = $Record.InvocationInfo.ScriptLineNumber
                Column    = $Record.InvocationInfo.OffsetInLine
            }
        }
        else {
            Write-Warning "$Alien"
        }
    }
}

Back to Top


Download

Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.

Back to Top


Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible. Something heartfelt about “Helping me, to help you…….?” or something like that…..I am sure you understand where I am coming from.

Issue

Back to Top