New-ALOpsExternalDeployer.ps1

function New-ALOpsExternalDeployer(){
    [CmdletBinding()]
    param
    (
        [string] $ServerInstance = "BC",
        [string] $ALOpsExternalDeployerEndpoint = "http://localhost:7040/",
        [string] $CustomScriptPath
    )
       
    Import-ALOpsNavManagementDlls -ServerInstance $ServerInstance

    Write-Host "*** Linking ServerInstance [$($ServerInstance)] to ALOps External Deployer [$($ALOpsExternalDeployerEndpoint)]"
    Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName "ExternalNavAppDeploymentEndpoint" -KeyValue $ALOpsExternalDeployerEndpoint

    $AppDeployDetails = @{ 
                             "ScriptFolder" = "$($CustomScriptPath)"; 
                             "ContainerId" = ""; 
                             "ServerInstance" = "$($ServerInstance)"; 
                             "Tenant" = "default"
                         }

    Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName LocalServiceApiKey -KeyValue ( $AppDeployDetails | ConvertTo-Json -Depth 100)

    if ((Get-NAVServerInstance -ServerInstance $ServerInstance).state -ilike "Running"){
        Restart-NAVServerInstance -ServerInstance $ServerInstance
    }
}