Private/Install-BusinessCentral.ps1

# Will be called in VM
function Global:Install-BusinessCentral {
    [CmdletBinding()]
    <#
    .SYNOPSIS
        ...
    .DESCRIPTION
        ...
    #>

    param(        
        [Parameter(Mandatory = $false, Position = 1)]
        [string]
        $DownloadDirectory = "C:\Install\DVD",
        [Parameter(Mandatory = $false, Position = 2)]
        [string]
        $ConfigurationFile = "https://raw.githubusercontent.com/SimonOfHH/PowerShell-Stuff/master/Modules/SetupD365Environment/assets/NavInstallConfiguration-App.xml",
        [Parameter(Mandatory = $false, Position = 3)]
        [string]
        $LicenseFilename
    )
    if (-not (Get-Module -Name Cloud.Ready.Software.NAV)){
        Write-Host "Importing Module Cloud.Ready.Software.NAV" 
        Import-Module Cloud.Ready.Software.NAV -Force -Verbose:$false -DisableNameChecking -WarningAction SilentlyContinue
    }
    $setupFilename = Join-Path $DownloadDirectory 'setup.exe'
    if (-not(Test-Path $setupFilename)){
        throw "$setupFilename doesn not exist. Make sure that 'DownloadDirectory' contains the path to the extracted DVD."
    }
    if (-not(Test-Path $ConfigurationFile)){
        $DestinationFilename = Join-Path (Split-Path $DownloadDirectory -Parent) (Split-Path $ConfigurationFile -Leaf)
        Download-CustomFile -URI $ConfigurationFile -DestinationFile $DestinationFilename
        $ConfigurationFile = $DestinationFilename
    }
    $LogPath = Join-Path (Split-Path $DownloadDirectory -Parent) '\Log\NavInstallLog.txt'
    Install-NAV -DVDFolder $DownloadDirectory -Configfile $ConfigurationFile -LicenseFile $LicenseFilename -Log $LogPath
}