functions/setup/Start-BcSetup.ps1

function Start-BcSetup {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [int]$MajorVersion,
        [Parameter(Mandatory=$true)]
        [int]$MinorVersion,
        [Parameter(Mandatory=$true)]
        [string]$CountryCode,
        [Parameter(Mandatory=$false)]
        [string]$DvdRepositoryPath = (Join-Path $env:SystemDrive 'DVD\BC'),
        [switch]$NoService,
        [switch]$InstallWebClient,
        [switch]$AcceptTOS,
        [string]$ServerInstance = "BC$($MajorVersion)0",
        [int]$ServicesPortRangeStart = $($MajorVersion) * 1000 + 44
    )

    $DvdPath = "$($DvdRepositoryPath)\$($MajorVersion)\$($MinorVersion)\$($CountryCode)"
    $MsiPath = "$($DvdPath)\ServiceTier\Microsoft Dynamics 365 Business Central Server.msi"

    $IsDvdReady = Test-Path $MsiPath -PathType Leaf

    if (-not $IsDvdReady)
    {
        $DvdZipPath = Get-BcDvd -MajorVersion $MajorVersion -MinorVersion $MinorVersion -CountryCode $CountryCode -DvdRepositoryPath $DvdRepositoryPath
        Expand-Archive -Path $DvdZipPath -DestinationPath $DvdPath 
    }

    if (-not $NoService)
    { 
        Install-Bc -DvdPath $DvdPath -Component Service `
            -ServerInstance $ServerInstance -ServicesPortRangeStart $ServicesPortRangeStart `
            -SOAPServicesEnabled -ODataServicesEnabled `
            -DeveloperServicesEnabled -SnapshotDebuggerEnabled `
            -AcceptTOS:$AcceptTOS
    }

    if ($InstallWebClient)
    {
        Install-Bc -DvdPath $DvdPath -Component WebClient -AcceptTOS:$AcceptTOS
    }
}