Testing/Install-BuildHelper.ps1

function Install-BuildHelper {
    param (
        # Container name to install the Build Helper into
        [Parameter(Mandatory=$false)]
        [string]
        $ContainerName = (Get-ContainerFromLaunchJson),
        # Whether to force a reinstall of the app
        [Parameter(Mandatory=$false)]
        [switch]
        $Reinstall
    )
    
    $Install = $false

    if ($Reinstall.IsPresent) {
        $Install = $true
    }
    else {
        #test for the existence of the build helper service
        try {
            $Uri = 'http://{0}:7047/NAV/WS/Codeunit/AutomatedTestMgt' -f (Get-NavContainerIpAddress $ContainerName)
            Invoke-WebRequest $Uri -Credential (New-CredentialFromEnvironmentJson) | Out-Null
        }
        catch {
            $Install = $true
        }
    }

    if ($Install) {
        $BuildHelperApp = Get-AppFromLastSuccessfulBuild -ProjectName 'TFS Tools' -RepositoryName BuildHelper
        Publish-NavContainerApp -containerName $ContainerName -appFile $BuildHelperApp.FullName -install -sync
    }
}

Export-ModuleMember -Function Install-BuildHelper