public/Get-SpeedTestConfig.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
<#
    .SYNOPSIS
    Get the default server configurations for Internet and Local speed test servers.

    .DESCRIPTION
    Get the default server configurations for Internet and Local speed test servers.
    Converts the JSON configuration file into a PSCustomObject.

    .EXAMPLE
    Get-SpeedTestConfig
#>


function Get-SpeedTestConfig {
    [CmdletBinding()]
    Param()

    try {
        $config = Get-Content -Path "$($PSScriptRoot | Split-Path -Parent)\config.json" -ErrorAction "Stop"
        return $config | ConvertFrom-Json
    }
    catch {
        throw "Can't find the JSON configuration file. Use 'Set-SpeedTestConfig' to create one."
    }
}