Source/Public/Get-ErrorDetail.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<#
.SYNOPSIS
Short description
 
.DESCRIPTION
Long description
 
.PARAMETER ExitCode
Parameter description
 
.PARAMETER LocalJSONFilePath
Parameter description
 
.PARAMETER GithubJSONUrl
Parameter description
 
.EXAMPLE
An example
 
.NOTES
General notes
#>

Function Get-ErrorDetail
{
    [cmdletbinding()]
    [alias("err")]
    Param(
        [Parameter(ValueFromPipeline = $true)] 
        [String] $ErrorCode
    )

    Begin
    {
        Try
        {
            $Data = Import-csv "$(Split-Path (Split-Path $PSScriptRoot))\Data\ErrorCode.csv"
        }
        Catch
        {
            "Something went wrong! please try running the script again."
        }
    }

    Process
    {
        Foreach ($Item in $ErrorCode)
        {
            If ($Item)
            {
                $Data | Where-Object {$_.exitCode -eq $ErrorCode}
            }
            else
            {
                $Data
                break;
            }
        }

    }

    End
    {}

}