Modules/businessdev.ALbuild.Containers/Public/Set-BcContainerServerConfig.ps1

function Set-BcContainerServerConfig {
    <#
    .SYNOPSIS
        Sets Business Central server configuration keys inside a container and restarts the instance.
 
    .PARAMETER Name
        Container name.
 
    .PARAMETER Settings
        Hashtable of configuration key/value pairs (Set-NAVServerConfiguration KeyName/KeyValue).
 
    .PARAMETER ServerInstance
        BC server instance inside the container. Default 'BC'.
 
    .PARAMETER NoRestart
        Apply the settings without restarting the server instance.
 
    .PARAMETER DockerExecutable
        The Docker executable to use (default 'docker').
 
    .EXAMPLE
        Set-BcContainerServerConfig -Name bld -Settings @{ ExtendedSecurityTokenLifetime = 24 }
    #>

    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [Alias('ContainerName')] [string] $Name,
        [Parameter(Mandatory)] [ValidateNotNull()] [hashtable] $Settings,
        [string] $ServerInstance = 'BC',
        [switch] $NoRestart,
        [string] $DockerExecutable = 'docker'
    )

    if (-not $PSCmdlet.ShouldProcess($Name, "Set $($Settings.Count) server configuration value(s)")) { return }

    $script = {
        foreach ($property in $Settings.PSObject.Properties) {
            Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName $property.Name -KeyValue ([string]$property.Value) -ErrorAction Stop
        }
        if (-not $NoRestart) {
            Set-NAVServerInstance -ServerInstance $ServerInstance -Restart -ErrorAction Stop
        }
        Write-Output "Applied configuration"
    }

    $output = Invoke-BcContainerCommand -ContainerName $Name -ScriptBlock $script -DockerExecutable $DockerExecutable -Variables @{
        ServerInstance = $ServerInstance
        Settings       = $Settings
        NoRestart      = [bool]$NoRestart
    }
    Write-ALbuildLog -Level Success ($output.Trim())
}