Public/Set-P1AdapterParameter.ps1

function Set-P1AdapterParameter {
    <#
    .Synopsis
    Set one parameter for the adapter.
 
    .Description
    Set an adapter parameter by name.
    Call Set-P1AdapterParameter with only the tenant name to get available parameters for it
    Some names are specific to some adapters.
 
    .Parameter Tenant
    The target tenant.
 
    .Parameter Name
    The parameter name.
 
    .Parameter Value
    The parameter value.
 
    .Example
    # Set the SynchroniztionTick parameter to 5 seconds
    Set-P1AdapterParameter -Tenant Prod -Name SynchronizationTick -Value 5
    #>

    [cmdletbinding()]
    param( 
        [Parameter(Mandatory=$true)]
        [string] $Tenant,
        [string] $Name,
        [string] $Value
    )
    Process
    {
        if (!(Test-Tenant $Tenant)) {
            Write-Warning "Tenant $Tenant does not exist."
            Write-Warning "Operation canceled."
            return
        }

        $tenantInfo = Get-TenantInfo $Tenant
        if ($tenantInfo -eq $null) {
                Write-Warning "No tenant information available"
                Write-Warning "Configuration canceled"
                return
        }

        $adapterType = $tenantInfo.Adapter
        if ($adapterType -eq "") {
            Write-Warning "No adapter define for tenant $Tenant"
            return
        }

        Write-Verbose "Adapter type is $adapterType"

        if ($adapterType -ne "NAV" -and $adapterType -ne "REST") {
            Write-Warning "Adapter type $adapterType is undefined or unrecognized"
            return
        }

        if ($Name -eq "" -and $Value -eq "") {
            if ($adapterType -eq "NAV") {
                Write-NAVValidParameters
            }

            if ($adapterType -eq "REST") {
                Write-RESTValidParameters
            }

            return
        }

        Write-Section "Set adapter parameter for tenant $Tenant, parameter $Name to value $Value"
        if (!(Test-Tenant $Tenant)) {
            Write-Warning "Tenant $Tenant does not exist."
            Write-Warning "Operation canceled."
            return;
        }

        if ($Name -eq "") {
            Write-Warning "Parameter name must be set"
            return;
        }

        if ($Value -eq "") {
            Write-Warning "Parameter value must be set. Value must be true or false for boolean values."
            return;
        }

        if ($adapterType -eq "NAV") {
            Set-NAVAdapterParameter $Tenant $Name $Value
        }

        if ($adapterType -eq "REST") {
            Set-RESTAdapterParameter $Tenant $Name $Value
        }

        Write-Warning "You must restart the server to enable the new parameter."
    }
}