Private/New-CounterConfigurationFromJson.ps1

function New-CounterConfigurationFromJson {
    [CmdletBinding()]
    [OutputType([System.Collections.Generic.List[psTPCCLASSES.CounterConfiguration]])]
    param(
        [Parameter(Mandatory=$true)]
        [PSCustomObject]    $JsonConfig,
        [Parameter(Mandatory=$true)]
        [System.Collections.Generic.Dictionary[int, string]] $counterMap,

        # Remote params
        [Parameter()]
        [bool]              $isRemote,
        [Parameter()]
        [string]            $computername,
        [Parameter()]
        [pscredential]      $credential
    )

    $PerformanceCounters = [System.Collections.Generic.List[psTPCCLASSES.CounterConfiguration]]::new()

    foreach ( $CounterConfig in $JsonConfig.counters ) {

        # Create CounterConfiguration Instance
        $CounterConfiguration = [psTPCCLASSES.CounterConfiguration]::new(
            $CounterConfig.counterID,
            $CounterConfig.counterSetType,
            $CounterConfig.counterInstance,
            $CounterConfig.title,
            $CounterConfig.type,
            $CounterConfig.format,
            $CounterConfig.unit,
            $CounterConfig.conversionFactor,
            $CounterConfig.conversionExponent,
            $CounterConfig.colorMap,
            $CounterConfig.graphConfiguration,
            $isRemote,
            $computername,
            $credential,
            $counterMap
        )

        $PerformanceCounters.Add($CounterConfiguration)
    }

    return $PerformanceCounters

}