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] $ConfigurationFileApp = "https://raw.githubusercontent.com/SimonOfHH/PowerShell-Stuff/master/Modules/SetupD365Environment/assets/NavInstallConfiguration-App.xml", [Parameter(Mandatory = $false, Position = 2)] [string] $ConfigurationFileWeb = "https://raw.githubusercontent.com/SimonOfHH/PowerShell-Stuff/master/Modules/SetupD365Environment/assets/NavInstallConfiguration-Web.xml", [Parameter(Mandatory = $false, Position = 3)] [string] $LicenseFilename, [ValidateSet('App','Web')] [Parameter(Mandatory = $false, Position = 3)] [string] $InstallationType = "App" ) # Check prerequisities 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." } # Check installation type switch ($InstallationType) { 'App' {$ConfigurationFile = $ConfigurationFileApp} 'Web' {$ConfigurationFile = $ConfigurationFileWeb} } # Check if it's necessary to download the config-file if (-not(Test-Path $ConfigurationFile)){ $DestinationFilename = Join-Path (Split-Path $DownloadDirectory -Parent) (Split-Path $ConfigurationFile -Leaf) Download-CustomFile -URI $ConfigurationFile -DestinationFile $DestinationFilename $ConfigurationFile = $DestinationFilename } # Start Install $LogPath = Join-Path (Split-Path $DownloadDirectory -Parent) '\Log\NavInstallLog.txt' Install-NAV -DVDFolder $DownloadDirectory -Configfile $ConfigurationFile -LicenseFile $LicenseFilename -Log $LogPath } |