Public/Get-PSAirTableConfiguration.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
function Get-PSAirTableConfiguration {
    <#
        .SYNOPSIS
            Queries the configuration stored as a JSON file in the module directory and returns as a PowerShell object.
    
        .EXAMPLE
            PS> Get-PSAirTableConfiguration

            Queries the configuration JSON file and returns values.
    
    #>

    [OutputType('string')]
    [CmdletBinding()]
    param
    ()

    $ErrorActionPreference = 'Stop'

    try {
        $configJsonPath = "$WorkingDir\Configuration.json"
        if (-not (Test-Path -Path $configJsonPath)) {
            throw 'The required Configuration.json file could not be found.'
        }

        Get-Content -Path $configJsonPath -Raw | ConvertFrom-Json
    } catch {
        $PSCmdlet.ThrowTerminatingError($_)
    }
}