functions/security/Test-BcService.ps1

function Test-BcService {
    [CmdletBinding(DefaultParameterSetName='ServerInstance')]
    param(
        [Parameter(Mandatory, ParameterSetName='ServerInstance', Position=0)]
        [string]$ServerInstance,
        
        [Parameter(Mandatory, ParameterSetName='ConfigurationPath')]
        [string]$ConfigurationPath
    )
    
    begin {
        $Configuration = Get-NAVServerConfiguration -ServerInstance $ServerInstance
        $Version = (Get-NAVServerInstance -ServerInstance $ServerInstance).Version
    }
    
    process {
        # Debugging output to check if $Configuration is correctly populated
        Write-Host "Configuration Count: $($Configuration.Count)"
        
        foreach ($entry in $Configuration) {
            $propertyName = $entry.Key
            $propertyValue = $entry.Value
            $recommendedValue = Get-RecommendedBcConfiguration -PropertyName $propertyName -Version $Version
        
            # Determine the color
            $color = Get-ColorForBcConfigurationValue -CurrentValue $propertyValue -RecommendedValue $recommendedValue
        
            # Print the result with the appropriate color
            Write-Host "$propertyName : $propertyValue" -ForegroundColor $color
        }
    }
    
    end {
        
    }
}

. C:\Repositories\ibs\extensions\BcAdmin\functions\common\Get-RecommendedBcConfiguration.ps1
. C:\Repositories\ibs\extensions\BcAdmin\functions\common\Get-ColorForBcConfigurationValue.ps1

Test-BcService -ServerInstance BC240