functions/setup/Install-Bc.ps1
function Install-Bc { [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string]$DvdPath, [Parameter(Mandatory=$true)] [ValidateSet('Service', 'WebClient')] [string]$Component, [switch]$AcceptTOS, [string]$ServerInstance = 'BC', [int]$ServicesPortRangeStart = 7044, [int]$ManagementApiServicesPort = $ServicesPortRangeStart, [int]$ManagementServicesPort = $ServicesPortRangeStart + 1, [int]$ClientServicesPort = $ServicesPortRangeStart + 2, [int]$SOAPServicesPort = $ServicesPortRangeStart + 3, [int]$ODataServicesPort = $ServicesPortRangeStart + 4, [int]$DeveloperServicesPort = $ServicesPortRangeStart + 5, [int]$SnapshotDebuggerServicesPort = $ServicesPortRangeStart + 6, [switch]$SOAPServicesEnabled, [switch]$ODataServicesEnabled, [switch]$DeveloperServicesEnabled, [switch]$SnapshotDebuggerEnabled ) if (-not $AcceptTOS) { throw 'You have to accept the terms of service to continue. Read this: https://learn.microsoft.com/de-de/dynamics365/business-central/dev-itpro/terms/legal-onpremises. If you agree you have to accept by using parameter -AcceptTOS.' } switch ($Component) { 'Service' { $MsiPath = (Join-Path "$($DvdPath)" 'ServiceTier\Microsoft Dynamics 365 Business Central Server.msi') $LogPath = (Join-Path "$($DvdPath)" 'ServiceTier.SetupLog.txt') } 'WebClient' { $MsiPath = (Join-Path "$($DvdPath)" 'WebClient\Microsoft Dynamics 365 Business Central Web Client.msi') $LogPath = (Join-Path "$($DvdPath)" 'WebClient.SetupLog.txt') } } if (Test-Path -Path $MsiPath -PathType Leaf) { $MsiArgumentList = " /quiet /log `"$LogPath`" /i `"$MsiPath`" SERVERINSTANCE=$($ServerInstance) MANAGEMENTAPISERVICESPORT=$($ManagementApiServicesPort) MANAGEMENTSERVICEPORT=$($ManagementServicesPort) SERVICEPORT=$($ClientServicesPort) WEBSERVICEPORT=$($SOAPServicesPort) DATASERVICEPORT=$($ODataServicesPort) DEVELOPERSERVICESPORT=$($DeveloperServicesPort) SNAPSHOTDEBUGGERSERVICESPORT=$($SnapshotDebuggerServicesPort) WEBSERVICEENABLED=$($SOAPServicesEnabled) DATASERVICEENABLED=$($ODataServicesEnabled) DEVELOPERSERVICESENABLED=$($DeveloperServicesEnabled) SNAPSHOTDEBUGGERENABLED=$($SnapshotDebuggerEnabled)" $ReturnCode = Start-Process msiexec.exe -ArgumentList $MsiArgumentList -Wait Write-Output $ReturnCode } else { Write-Error "MSI not found: $($MsiPath)" } } |