Private/Get-KeyValue.ps1

Function Get-KeyValue {

    ################################################################################
    ##### #####
    ##### Read Settings from JSON File #####
    ##### #####
    ################################################################################

    Param([string] $key)

    $CurrentFunction = Get-FunctionName
    Write-Log -Message "### Start Function $CurrentFunction ###"
    $StartRunTime = (Get-Date).ToString($Script:DateFormatLog)
    #################### main code | out- host ####################

    $json = Get-Content -Path $Script:ConfigFile | ConvertFrom-Json
    $value = ($json.DefaultParameter.Setting | Where-Object { $_.Name -eq $key }).Value

    Write-Log -Message " >> using $key with value $value"
    ######################## main code ############################
    $runtime = Get-RunTime -StartRunTime $StartRunTime
    Write-Log -Message " Run Time: $runtime [h] ###"
    Write-Log -Message "### End Function $CurrentFunction ###"

    return $value
}