2020-07-05 11:09:50 +03:00
Param (
2020-07-05 14:06:43 +03:00
[ switch ] $skipContainerHelperCheck ,
2020-07-15 12:22:08 +03:00
[ string ] $predefinedpw = 'P@ssw0rd'
2020-07-05 11:09:50 +03:00
)
# create script for running docker
2020-07-03 14:39:49 +03:00
$ErrorActionPreference = " stop "
function Select-Value {
2020-07-03 09:42:26 +03:00
Param (
2020-07-03 14:39:00 +03:00
[ Parameter ( Mandatory = $false ) ]
2020-07-03 09:42:26 +03:00
[ string ] $title ,
2020-07-03 14:39:00 +03:00
[ Parameter ( Mandatory = $false ) ]
2020-07-03 09:42:26 +03:00
[ string ] $description ,
[ Parameter ( Mandatory = $true ) ]
$options ,
2020-07-03 14:39:00 +03:00
[ Parameter ( Mandatory = $false ) ]
[ string ] $default = " " ,
2020-07-03 09:42:26 +03:00
[ Parameter ( Mandatory = $true ) ]
2020-07-03 14:39:00 +03:00
[ string ] $question ,
[ switch ] $doNotClearHost = ( $host . name -ne " ConsoleHost " ) ,
2020-07-13 16:27:37 +03:00
[ switch ] $writeAnswer = ( $host . name -ne " ConsoleHost " ) ,
2020-07-21 15:27:36 +03:00
[ switch ] $previousStep
2020-07-03 09:42:26 +03:00
)
2020-07-03 14:39:00 +03:00
if ( ! $doNotClearHost ) {
Clear-Host
}
2020-07-21 15:27:36 +03:00
2020-07-03 14:39:00 +03:00
if ( $title ) {
Write-Host -ForegroundColor Yellow $title
Write-Host
}
if ( $description ) {
Write-Host $description
Write-Host
}
2020-07-03 09:42:26 +03:00
$offset = 0
$defaultChr = -1
$keys = @ ( )
$values = @ ( )
2020-07-13 16:27:37 +03:00
2020-07-03 09:42:26 +03:00
$options . GetEnumerator ( ) | ForEach-Object {
Write-Host -ForegroundColor Yellow " $( [ char ] ( $offset + 97 ) ) " -NoNewline
$keys + = @ ( $_ . Key )
$values + = @ ( $_ . Value )
if ( $_ . Key -eq $default ) {
Write-Host -ForegroundColor Yellow $_ . Value
$defaultAnswer = $offset
}
else {
Write-Host $_ . Value
}
$offset + +
}
Write-Host
2020-07-21 15:27:36 +03:00
if ( $script:thisStep -lt 100 ) {
2020-07-15 12:22:08 +03:00
if ( ( $default ) -and ! $script:acceptDefaults ) {
Write-Host -ForegroundColor Yellow " ! " -NoNewline
Write-Host " accept default answers for the remaining questions "
}
2020-07-21 15:27:36 +03:00
if ( $previousStep ) {
2020-07-15 12:22:08 +03:00
Write-Host -ForegroundColor Yellow " x " -NoNewline
Write-Host " start over "
Write-Host -ForegroundColor Yellow " z " -NoNewline
2020-07-21 15:27:36 +03:00
Write-Host " go back "
2020-07-15 12:22:08 +03:00
}
2020-07-21 15:27:36 +03:00
if ( ( $default ) -or ( $previousStep ) ) {
2020-07-15 12:22:08 +03:00
Write-Host
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 09:42:26 +03:00
$answer = -1
do {
Write-Host " $question " -NoNewline
if ( $defaultAnswer -ge 0 ) {
Write-Host " (default $( [ char ] ( $defaultAnswer + 97 ) ) ) " -NoNewline
}
2020-07-15 01:49:02 +03:00
if ( $script:acceptDefaults -and $defaultAnswer -ge 0 ) {
$selection = " "
}
else {
$selection = ( Read-Host ) . ToLowerInvariant ( )
}
if ( $selection -eq " ! " -and ( $default ) ) {
$selection = " "
$script:acceptDefaults = $true
Write-Host $defaultAnswer
}
2020-07-21 15:27:36 +03:00
if ( $previousStep ) {
2020-07-13 18:16:10 +03:00
if ( $selection -eq " x " ) {
if ( $writeAnswer ) {
Write-Host
Write-Host -ForegroundColor Green " Start over selected "
Write-Host
}
2020-07-15 01:49:02 +03:00
$script:acceptDefaults = $false
2020-07-13 18:16:10 +03:00
$script:wizardStep = 0
2020-07-21 15:27:36 +03:00
$script:prevSteps = New-Object System . Collections . Stack
$script:prevSteps . Push ( 1 )
2020-07-13 18:16:10 +03:00
return " Back "
2020-07-13 16:27:37 +03:00
}
2020-07-13 18:16:10 +03:00
if ( $selection -eq " z " ) {
if ( $writeAnswer ) {
Write-Host
Write-Host -ForegroundColor Green " Back selected "
Write-Host
}
2020-07-15 01:49:02 +03:00
$script:acceptDefaults = $false
2020-07-21 15:27:36 +03:00
$script:wizardStep = $script:prevSteps . Pop ( )
2020-07-13 18:16:10 +03:00
return " Back "
2020-07-13 16:27:37 +03:00
}
}
2020-07-03 09:42:26 +03:00
if ( $selection -eq " " ) {
if ( $defaultAnswer -ge 0 ) {
$answer = $defaultAnswer
}
else {
Write-Host -ForegroundColor Red " No default value exists. " -NoNewline
}
}
else {
if ( ( $selection . Length -ne 1 ) -or ( ( [ int][char ] ( $selection ) ) -lt 97 -or ( [ int][char ] ( $selection ) ) -ge ( 97 + $offset ) ) ) {
Write-Host -ForegroundColor Red " Illegal answer. " -NoNewline
}
else {
$answer = ( [ int][char ] ( $selection ) ) -97
}
}
if ( $answer -eq -1 ) {
if ( $offset -eq 2 ) {
Write-Host -ForegroundColor Red " Please answer one letter, a or b "
}
else {
Write-Host -ForegroundColor Red " Please answer one letter, from a to $( [ char ] ( $offset + 97 - 1 ) ) "
}
}
} while ( $answer -eq -1 )
2020-07-03 14:39:00 +03:00
if ( $writeAnswer ) {
Write-Host
Write-Host -ForegroundColor Green " $( $values [ $answer ] ) selected "
Write-Host
}
2020-07-03 09:42:26 +03:00
$keys [ $answer ]
}
function Enter-Value {
Param (
2020-07-03 14:39:00 +03:00
[ Parameter ( Mandatory = $false ) ]
2020-07-03 09:42:26 +03:00
[ string ] $title ,
2020-07-03 14:39:00 +03:00
[ Parameter ( Mandatory = $false ) ]
2020-07-03 09:42:26 +03:00
[ string ] $description ,
[ Parameter ( Mandatory = $false ) ]
$options ,
2020-07-03 14:39:00 +03:00
[ Parameter ( Mandatory = $false ) ]
2020-07-03 09:42:26 +03:00
[ string ] $default = " " ,
[ Parameter ( Mandatory = $true ) ]
2020-07-03 14:39:00 +03:00
[ string ] $question ,
[ switch ] $doNotClearHost = ( $host . name -ne " ConsoleHost " ) ,
2020-07-06 14:22:50 +03:00
[ switch ] $writeAnswer = ( $host . name -ne " ConsoleHost " ) ,
2020-07-13 16:27:37 +03:00
[ switch ] $doNotConvertToLower ,
2020-07-21 15:27:36 +03:00
[ switch ] $previousStep
2020-07-03 09:42:26 +03:00
)
2020-07-03 14:39:00 +03:00
if ( ! $doNotClearHost ) {
Clear-Host
}
2020-07-21 15:27:36 +03:00
2020-07-03 14:39:00 +03:00
if ( $title ) {
Write-Host -ForegroundColor Yellow $title
Write-Host
}
if ( $description ) {
Write-Host $description
2020-07-03 09:42:26 +03:00
Write-Host
}
2020-07-21 15:27:36 +03:00
if ( $script:thisStep -lt 100 ) {
2020-07-15 12:22:08 +03:00
if ( ( $default ) -and ! $script:acceptDefaults ) {
Write-Host -ForegroundColor Yellow " ! " -NoNewline
Write-Host " accept default answers for the remaining questions "
}
2020-07-21 15:27:36 +03:00
if ( $previousStep ) {
2020-07-15 12:22:08 +03:00
Write-Host " Enter " -NoNewline
Write-Host -ForegroundColor Yellow " x " -NoNewline
Write-Host " to start over "
Write-Host " Enter " -NoNewline
Write-Host -ForegroundColor Yellow " z " -NoNewline
2020-07-21 15:27:36 +03:00
Write-Host " to go back "
2020-07-15 12:22:08 +03:00
}
2020-07-21 15:27:36 +03:00
if ( ( $default ) -or ( $previousStep ) ) {
2020-07-15 12:22:08 +03:00
Write-Host
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 09:42:26 +03:00
$answer = " "
do {
Write-Host " $question " -NoNewline
2020-07-03 14:39:00 +03:00
if ( $options ) {
Write-Host " ( $( [ string ] :: Join ( ', ' , $options ) ) ) " -NoNewline
}
2020-07-03 09:42:26 +03:00
if ( $default ) {
Write-Host " (default $default ) " -NoNewline
}
2020-07-15 01:49:02 +03:00
if ( $script:acceptDefaults -and ( $default ) ) {
$selection = " "
Write-Host $default
}
elseif ( $doNotConvertToLower ) {
2020-07-06 14:22:50 +03:00
$selection = Read-Host
}
else {
$selection = ( Read-Host ) . ToLowerInvariant ( )
}
2020-07-15 01:49:02 +03:00
if ( $selection -eq " ! " -and ( $default ) ) {
$selection = " "
$script:acceptDefaults = $true
}
2020-07-03 09:42:26 +03:00
if ( $selection -eq " " ) {
if ( $default ) {
$answer = $default
}
else {
2020-07-03 14:39:00 +03:00
Write-Host -ForegroundColor Red " No default value exists. "
2020-07-03 09:42:26 +03:00
}
}
2020-07-21 15:27:36 +03:00
elseif ( $selection -eq " x " -and $previousStep ) {
2020-07-13 16:27:37 +03:00
if ( $writeAnswer ) {
Write-Host
Write-Host -ForegroundColor Green " Exit selected "
Write-Host
}
2020-07-15 01:49:02 +03:00
$script:acceptDefaults = $false
2020-07-13 18:16:10 +03:00
$script:wizardStep = 0
2020-07-21 15:27:36 +03:00
$script:prevSteps = New-Object System . Collections . Stack
$script:prevSteps . Push ( 1 )
2020-07-13 18:16:10 +03:00
return " back "
2020-07-13 16:27:37 +03:00
}
2020-07-21 15:27:36 +03:00
elseif ( $selection -eq " z " -and $previousStep ) {
2020-07-13 16:27:37 +03:00
if ( $writeAnswer ) {
Write-Host
Write-Host -ForegroundColor Green " Back selected "
Write-Host
}
2020-07-15 01:49:02 +03:00
$script:acceptDefaults = $false
2020-07-21 15:27:36 +03:00
$script:wizardStep = $script:prevSteps . Pop ( )
2020-07-13 16:27:37 +03:00
return " back "
}
2020-07-03 09:42:26 +03:00
else {
if ( $options ) {
2022-05-13 08:09:21 +03:00
$answer = $options | Where-Object { $_ -eq $selection }
2020-07-03 09:42:26 +03:00
if ( -not ( $answer ) ) {
2022-05-13 08:09:21 +03:00
$answer = $options | Where-Object { $_ -like " $selection * " }
if ( -not ( $answer ) ) {
Write-Host -ForegroundColor Red " Illegal answer. Please answer one of the options. "
}
elseif ( $answer -is [ Array ] ) {
Write-Host -ForegroundColor Red " Multiple options match the answer. Please answer one of the options that matched the previous selection. "
$options = $answer
$answer = $null
}
2020-07-03 09:42:26 +03:00
}
}
else {
$answer = $selection
}
}
} while ( -not ( $answer ) )
2020-07-03 14:39:00 +03:00
if ( $writeAnswer ) {
Write-Host
Write-Host -ForegroundColor Green " $answer selected "
Write-Host
}
2020-07-03 09:42:26 +03:00
$answer
}
2020-07-05 11:09:50 +03:00
function randomchar([string]$str )
{
$rnd = Get-Random -Maximum $str . length
[ string ] $str [ $rnd ]
}
function Get-RandomPassword {
$cons = 'bcdfghjklmnpqrstvwxz'
$voc = 'aeiouy'
$numbers = '0123456789'
( ( randomchar $cons ) . ToUpper ( ) + `
( randomchar $voc ) + `
( randomchar $cons ) + `
( randomchar $voc ) + `
( randomchar $numbers ) + `
( randomchar $numbers ) + `
( randomchar $numbers ) + `
( randomchar $numbers ) )
}
2020-07-03 14:39:00 +03:00
Clear-Host
2020-07-21 15:27:36 +03:00
$pshost = Get-Host
$pswindow = $pshost . UI . RawUI
$minWidth = 150
if ( ( $pswindow . BufferSize ) -and ( $pswindow . WindowSize ) -and ( $pswindow . WindowSize . Width -lt $minWidth ) ) {
$buffersize = $pswindow . BufferSize
$buffersize . width = $minWidth
2020-10-22 08:49:49 +03:00
try {
$pswindow . buffersize = $buffersize
}
catch { }
2020-07-21 15:27:36 +03:00
$newsize = $pswindow . windowsize
$newsize . width = $minWidth
2020-10-22 08:49:49 +03:00
try {
$pswindow . windowsize = $newsize
}
catch { }
2020-07-21 15:27:36 +03:00
}
2020-07-13 16:27:37 +03:00
$currentPrincipal = New-Object Security . Principal . WindowsPrincipal ( [ Security.Principal.WindowsIdentity ] :: GetCurrent ( ) )
$isAdministrator = $currentPrincipal . IsInRole ( [ Security.Principal.WindowsBuiltInRole ] :: Administrator )
2020-07-06 14:22:50 +03:00
$randompw = Get-RandomPassword
2020-07-15 02:08:00 +03:00
$bestContainerOsVersion = [ System.Version ] ( ( Get-BestGenericImageName ) . Split ( ':' ) [ 1 ] ) . Split ( '-' ) [ 0 ]
2020-07-04 10:07:32 +03:00
$ErrorActionPreference = " STOP "
2020-07-21 15:27:36 +03:00
2020-07-14 12:53:42 +03:00
$script:wizardStep = 0
2020-07-15 01:49:02 +03:00
$script:acceptDefaults = $false
2020-07-13 16:27:37 +03:00
2020-07-21 15:27:36 +03:00
$Step = @ {
2020-08-03 12:06:07 +03:00
" BcContainerHelper " = 0
2020-07-21 15:27:36 +03:00
" AcceptEula " = 1
" Hosting " = 2
" Authentication " = 3
" ContainerName " = 4
" Version " = 5
2020-09-02 18:07:29 +03:00
" Version2 " = 7
" Country " = 8
" TestToolkit " = 9
" PerformanceToolkit " = 10
" PremiumPlan " = 11
" CreateTestUsers " = 12
2020-08-24 20:30:52 +03:00
" IncludeAL " = 20
" ExportAlSource " = 21
" IncludeCSIDE " = 22
" ExportCAlSource " = 23
2020-09-03 17:46:51 +03:00
" Vsix " = 24
2020-08-24 20:30:52 +03:00
" License " = 30
" Database " = 31
" Multitenant " = 32
" DNS " = 35
" SSL " = 36
" Isolation " = 40
" Memory " = 41
2020-07-21 15:27:36 +03:00
" SaveImage " = 50
" Special " = 60
" Final " = 100
}
$script:prevSteps = New-Object System . Collections . Stack
$script:prevSteps . Push ( 1 )
2020-07-13 16:27:37 +03:00
2020-07-21 15:27:36 +03:00
while ( $script:wizardStep -le 100 ) {
2020-07-13 16:27:37 +03:00
2020-07-21 15:27:36 +03:00
$script:thisStep = $script:wizardStep
2020-07-14 12:53:42 +03:00
$script:wizardStep + +
2020-07-13 16:27:37 +03:00
2020-07-21 15:27:36 +03:00
switch ( $script:thisStep ) {
2020-08-03 12:06:07 +03:00
$Step . BcContainerHelper {
2022-09-19 08:32:25 +03:00
Write-Host -ForegroundColor Yellow @ '
____ _____ _ _ _ _ _
| _ \ / ____ | | | ( _ ) | | | | | |
| | _ ) | ___ | | ___ _ __ | | _ __ _ _ _ __ ___ _ __ | | __ | | ___ | | _ __ ___ _ __
| _ < / __ | | / _ \ | '_ \| __/ _` | | ' _ \ / _ \ '__| __ |/ _ \ | ' _ \ / _ \ ' __ |
| | _ ) | ( __ | | ____ ( _ ) | | | | | _ ( _ | | | | | | __ / | | | | | __ / | | _ ) | __ / |
| ____ / \ ___ | \ _____ \ ___ / | _ | | _ | \ __ \ __ , _ | _ | _ | | _ | \ ___ | _ | | _ | | _ | \ ___ | _ | . __ / \ ___ | _ |
| |
| _ |
' @
2020-07-13 16:27:37 +03:00
if ( ! $skipContainerHelperCheck ) {
2020-08-03 12:06:07 +03:00
$module = Get-InstalledModule -Name " BcContainerHelper " -ErrorAction SilentlyContinue
2020-07-13 16:27:37 +03:00
if ( ! ( $module ) ) {
2020-08-03 12:06:07 +03:00
$module = Get-Module -Name " BcContainerHelper " -ErrorAction SilentlyContinue
2020-07-13 16:27:37 +03:00
}
if ( ! ( $module ) ) {
2020-08-03 12:06:07 +03:00
Write-Host -ForegroundColor Red " This script has a dependency on the PowerShell module BcContainerHelper. "
Write-Host -ForegroundColor Red " See more here: https://www.powershellgallery.com/packages/bccontainerhelper "
Write-Host -ForegroundColor Red " Use 'Install-Module BcContainerHelper -force' to install in PowerShell "
2020-07-05 14:06:43 +03:00
return
}
2022-09-19 08:32:25 +03:00
elseif ( $module . Version -eq " 0.0 " ) {
Write-Host -ForegroundColor Green " You are running BcContainerHelper developer version "
Write-Host
}
2020-07-05 14:06:43 +03:00
else {
2020-07-13 16:27:37 +03:00
$myVersion = $module . Version . ToString ( )
2020-08-03 12:06:07 +03:00
$prerelease = $myVersion . Contains ( " -preview " )
if ( $prerelease ) {
$latestVersion = ( Find-Module -Name bccontainerhelper -AllowPrerelease ) . Version
$previewStr = " Prerelease version "
}
else {
$latestVersion = ( Find-Module -Name bccontainerhelper ) . Version
$previewStr = " "
}
2020-07-13 16:27:37 +03:00
if ( $latestVersion -eq $myVersion ) {
2020-08-03 12:06:07 +03:00
Write-Host -ForegroundColor Green " You are running BcContainerHelper $previewStr $myVersion (which is the latest version) "
2020-07-13 16:27:37 +03:00
}
else {
2020-08-03 12:06:07 +03:00
Write-Host -ForegroundColor Yellow " You are running BcContainerHelper $previewStr $myVersion . A newer version ( $latestVersion ) exists, please consider updating. "
2020-07-13 16:27:37 +03:00
}
Write-Host
2020-07-05 14:06:43 +03:00
}
2020-07-05 10:04:43 +03:00
}
2020-07-04 10:07:32 +03:00
}
2020-07-03 09:42:26 +03:00
2020-07-21 15:27:36 +03:00
$Step . AcceptEula {
2020-07-13 16:27:37 +03:00
$acceptEula = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_ ______ _
/ \ | | | ____ | | |
/ \ ___ ___ ___ _ __ | | _ | | __ _ _ | | __ _
/ / \ \ / __ / __ / _ \ ' _ \ | __ | | __ | | | | | | / _ ` |
/ ____ \ ( __ ( __ __ / | _ ) | | _ | | ____ | _ | | | ( _ | |
/ _ / \ _ \ ___ \ ___ \ ___ | . __ / \ __ | | ______ \ __ , _ | _ | \ __ , _ |
| |
| _ |
' @ `
2020-07-13 16:27:37 +03:00
-Description " This script will generate a script, which can be used to run Business Central in Docker on your computer. `n You will be asked a number of questions and the generated script should create a container, which matches your needs. `n `n In order to run Business Central in Docker, you will need to accept the eula. `n The supplemental license terms for running Business Central and NAV on Docker can be found here: https://go.microsoft.com/fwlink/?linkid=861843 " `
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you accept the eula "
if ( $acceptEula -ne " Y " ) {
Write-Host -ForegroundColor Red " Eula not accepted, aborting... "
return
}
2020-07-21 15:27:36 +03:00
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-03 09:42:26 +03:00
}
2020-07-21 15:27:36 +03:00
$Step . Hosting {
2020-07-13 16:27:37 +03:00
$hosting = Select-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_ _ _____ _ _ __ ____ __
| | | | / ____ | | | ( _ ) / \ \ \ / / \ / |
| | ___ ___ __ _ | | | | ___ _ __ | | _ __ _ _ _ __ ___ _ __ ___ _ __ / \ _____ _ _ __ ___ \ \ / / | \ / |
| | / _ \ / __ / _ ` | | | | / _ \ | '_ \| __/ _` | | ' _ \ / _ \ '__| / _ \| ' __ | / / \ \ | _ / | | | ' __ / _ \ \ \ / / | | \ / | |
| | ____ ( _ ) | ( __ ( _ | | | | | ____ ( _ ) | | | | | _ ( _ | | | | | | __ / | | ( _ ) | | / ____ \ / / | | _ | | | | __ / \ / | | | |
| ______ \ ___ / \ ___ \ __ , _ | _ | \ _____ \ ___ / | _ | | _ | \ __ \ __ , _ | _ | _ | | _ | \ ___ | _ | \ ___ / | _ | / _ / \ _ \ ___ | \ __ , _ | _ | \ ___ | \ / | _ | | _ |
' @ `
2020-07-13 16:27:37 +03:00
-description " Specify where you want to host your Business Central container? `n `n Selecting Local will create a script that needs to run on a computer, which have Docker installed. `n Selecting Azure VM shows a Url with which you can create a VM. This requires an Azure Subscription. " `
-options ( [ ordered ] @ { " Local " = " Local docker container " ; " AzureVM " = " Docker container in an Azure VM " } ) `
-question " Hosting " `
-default " Local " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-03 14:39:00 +03:00
}
2020-07-21 15:27:36 +03:00
$Step . Authentication {
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
2020-07-21 15:27:36 +03:00
2020-07-13 16:27:37 +03:00
$auth = Select-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_ _ _ _ _ _
/ \ | | | | | | ( _ ) | | ( _ )
/ \ _ _ | | _ | | __ ___ _ __ | | _ _ ___ __ _ | | _ _ ___ _ __
/ / \ \ | | | | __ | '_ \ / _ \ ' _ \ | __ | | / __ / _ ` | __ | | / _ \ | ' _ \
/ ____ \ | _ | | | _ | | | | __ / | | | | _ | | ( __ ( _ | | | _ | | ( _ ) | | | |
/ _ / \ _ \ __ , _ | \ __ | _ | | _ | \ ___ | _ | | _ | \ __ | _ | \ ___ \ __ , _ | \ __ | _ | \ ___ / | _ | | _ |
' @ `
2020-07-13 16:27:37 +03:00
-description " Select desired authentication mechanism. `n Selecting predefined credentials means that the script will use hardcoded credentials. `n `n Note: When using Windows authentication, you need to use your Windows Credentials from the host computer and if the computer is domain joined, you will need to be connected to the domain while running the container. You cannot use containers with Windows authentication when offline. " `
-options ( [ ordered ] @ { " UserPassword " = " Username/Password authentication " ; " Credential " = " Username/Password authentication (admin with predefined password - $predefinedpw ) " ; " Random " = " Username/Password authentication (admin with random password - $randompw ) " ; " Windows " = " Windows authentication " } ) `
-question " Authentication " `
-default " Credential " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-05 14:06:43 +03:00
}
else {
2020-07-13 16:27:37 +03:00
$auth = " UserPassword "
2020-07-03 14:39:00 +03:00
}
}
2020-07-05 14:06:43 +03:00
2020-07-21 15:27:36 +03:00
$Step . ContainerName {
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
2020-07-21 15:27:36 +03:00
2020-07-13 16:27:37 +03:00
$containerName = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_____ _ _ _ _
/ ____ | | | ( _ ) | \ | |
| | ___ _ __ | | _ __ _ _ _ __ ___ _ __ | \ | | __ _ _ __ ___ ___
| | / _ \ | '_ \| __/ _` | | ' _ \ / _ \ '__| | . ` |/ _` | ' _ ` _ \ / _ \
| | ____ ( _ ) | | | | | _ ( _ | | | | | | __ / | | | \ | ( _ | | | | | | | __ /
\ _____ \ ___ / | _ | | _ | \ __ \ __ , _ | _ | _ | | _ | \ ___ | _ | | _ | \ _ | \ __ , _ | _ | | _ | | _ | \ ___ |
' @ `
2020-07-13 16:27:37 +03:00
-description " Enter the name of the container. `n Container names are case sensitive and must start with a letter. `n `n Note: We recommend short lower case names as container names. " `
-question " Container name " `
2020-10-21 19:11:08 +03:00
-default " bcserver " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-05 14:06:43 +03:00
}
else {
2020-07-31 10:16:25 +03:00
$containerName = $bcContainerHelperConfig . defaultContainerName
2020-07-05 14:06:43 +03:00
}
2020-07-13 16:27:37 +03:00
}
2020-07-05 14:06:43 +03:00
2020-07-21 15:27:36 +03:00
$Step . Version {
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " local " ) { $back = 4 } else { $back = 2 }
$predef = Select-Value `
2020-07-21 15:27:36 +03:00
-title @ '
__ __ _
\ \ / / ( _ )
\ \ / / __ _ __ ___ _ ___ _ __
\ \ / / _ \ '__/ __| |/ _ \| ' _ \
\ / __ / | \ __ \ | ( _ ) | | | |
\ / \ ___ | _ | | ___ / _ | \ ___ / | _ | | _ |
' @ `
2020-07-13 16:27:37 +03:00
-description " What version of Business Central do you need? `n If you are developing a Per Tenant Extension for a Business Central Saas tenant, you need a Business Central Sandbox environment " `
2020-09-02 18:07:29 +03:00
-options ( [ ordered ] @ {
" LatestSandbox " = " Latest Business Central Sandbox "
" LatestOnPrem " = " Latest Business Central OnPrem "
2023-09-27 16:09:36 +03:00
" Next Major " = " Insider Business Central Sandbox for Next Major release (you automatically accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) by using this option) "
" Next Minor " = " Insider Business Central Sandbox for Next Minor release (you automatically accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) by using this option) "
2020-09-02 18:07:29 +03:00
" SpecificSandbox " = " Specific Business Central Sandbox build (requires version number) "
" SpecificOnPrem " = " Specific Business Central OnPrem build (requires version number) "
2020-09-03 17:46:51 +03:00
" NAV2018 " = " Specific NAV 2018 version "
" NAV2017 " = " Specific NAV 2017 version "
" NAV2016 " = " Specific NAV 2016 version "
2020-09-02 18:07:29 +03:00
} ) `
2020-07-13 16:27:37 +03:00
-question " Version " `
-default " LatestSandbox " `
-writeAnswer `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 14:39:00 +03:00
2020-07-21 15:27:36 +03:00
$Step . Version2 {
2020-07-13 16:27:37 +03:00
$fullVersionNo = $false
$select = " Latest "
2020-09-02 18:07:29 +03:00
$storageAccount = " bcartifacts "
2020-09-03 17:46:51 +03:00
$nav = " "
2020-07-13 16:27:37 +03:00
if ( $predef -like " latest* " ) {
$type = $predef . Substring ( 6 )
$version = ''
}
2020-09-02 18:07:29 +03:00
elseif ( $predef -like " Next* " ) {
$type = " Sandbox "
$version = ''
$storageAccount = " bcinsider "
if ( $predef -eq " Next Minor " ) {
$select = " SecondToLastMajor "
}
}
2020-09-03 17:46:51 +03:00
elseif ( $predef -like " NAV* " ) {
$nav = $predef . Substring ( 3 )
$type = " Onprem "
$ok = $false
do {
$cus = Get-NavArtifactUrl -nav $nav -country 'w1' -select All
$cu = Enter-Value `
-description " NAV $nav has $( $cus . Count - 1 ) released cumulative updates. " `
-question " Enter CU number (0 is rtm or leave blank for latest) " `
-default " latest " `
-doNotClearHost `
-writeAnswer `
-previousStep
if ( $cu -eq " back " ) {
$ok = $true
}
else {
$cuno = $cus . Count - 1
if ( $cu -eq " latest " -or ( [ int ] :: TryParse ( $cu , [ ref ] $cuno ) -and ( $cuno -ge 0 ) -and ( $cuno -lt $ ( $cus . Count ) ) ) ) {
$ok = $true
$version = $cus [ $cuno ] . split ( '/' ) [ 4 ]
}
}
} while ( ! $ok )
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
}
2020-07-13 16:27:37 +03:00
elseif ( $predef -like " specific* " ) {
$type = $predef . Substring ( 8 )
$ok = $false
do {
$version = Enter-Value `
-description " Specify version number. `n If you specify a full version number (like 15.4.41023.41345), you will get the closest version. `n If multiple versions matches the entered value, you will be asked to select " `
-question " Enter version number (format major[.minor[.build[.release]]]) " `
-doNotClearHost `
-writeAnswer `
2020-07-21 15:27:36 +03:00
-previousStep
2020-07-13 16:27:37 +03:00
2020-07-13 18:16:10 +03:00
if ( $version -eq " back " ) {
2020-07-13 16:27:37 +03:00
$ok = $true
2020-07-03 14:39:00 +03:00
}
2020-07-13 16:27:37 +03:00
else {
if ( $version . indexOf ( '.' ) -eq -1 ) {
$verno = 0
$ok = [ int32 ] :: TryParse ( $version , [ ref ] $verno )
if ( ! $ok ) {
Write-Host -ForegroundColor Red " Illegal version number "
2020-07-03 14:39:00 +03:00
}
}
else {
2020-07-13 16:27:37 +03:00
$verno = [ Version ] " 0.0.0.0 "
$ok = [ Version ] :: TryParse ( $version , [ ref ] $verno )
if ( ! $ok ) {
Write-Host -ForegroundColor Red " Illegal version number "
}
$fullVersionNo = $verno . Revision -ne -1
2020-07-03 14:39:00 +03:00
}
2020-07-13 16:27:37 +03:00
2020-07-03 14:39:00 +03:00
if ( $ok ) {
2020-07-13 16:27:37 +03:00
if ( $fullVersionNo ) {
$select = " Closest "
$artifactUrl = Get-BCArtifactUrl -type $type -version $version -country 'w1' -select 'Closest'
if ( $artifactUrl ) {
$foundVersion = $artifactUrl . split ( '/' ) [ 4 ]
if ( $foundVersion -ne $version ) {
Write-Host -ForegroundColor Yellow " The specific version doesn't exist, closest version is $foundVersion "
}
}
}
else {
$versions = @ ( )
Get-BCArtifactUrl -type $type -version $version -country 'w1' -select All | ForEach-Object {
$versions + = $_ . Split ( '/' ) [ 4 ]
}
if ( $versions . Count -eq 0 ) {
Write-Host -ForegroundColor Red " Unable to find a version matching the specified version "
$ok = $false
}
elseif ( $versions . Count -gt 1 ) {
$version = Enter-Value `
-options $versions `
-question " Select specific version " `
-doNotClearHost `
-writeAnswer `
2020-07-21 15:27:36 +03:00
-previousStep
2020-07-13 16:27:37 +03:00
2020-07-13 18:16:10 +03:00
if ( $version -eq " back " ) {
2020-07-13 16:27:37 +03:00
$ok = $true
}
else {
$fullVersionNo = $true
}
}
2020-07-03 14:39:00 +03:00
}
}
}
2020-07-13 16:27:37 +03:00
} while ( ! $ok )
2020-07-21 15:27:36 +03:00
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 14:39:00 +03:00
}
2020-07-03 09:42:26 +03:00
2020-07-21 15:27:36 +03:00
$Step . Country {
2020-07-03 09:42:26 +03:00
2023-01-29 12:55:55 +03:00
Write-Host " Analyzing artifacts "
2020-09-02 18:07:29 +03:00
$versionno = $version
if ( $versionno -eq " " ) {
2022-09-19 08:32:25 +03:00
$searchCountry = " us "
2023-01-29 12:55:55 +03:00
if ( $type -eq 'sandbox' ) { $searchCountry = " at " }
2023-09-27 16:09:36 +03:00
$aurl = Get-BcArtifactUrl -storageAccount $storageAccount -type $type -country $searchCountry -select $select -accept_insiderEula
2022-09-19 08:32:25 +03:00
$versionno = $aurl . split ( '/' ) [ 4 ]
2020-09-02 18:07:29 +03:00
}
$majorVersion = [ int ] ( $versionno . Split ( '.' ) [ 0 ] )
$countries = @ ( )
2023-09-27 16:09:36 +03:00
Get-BCArtifactUrl -storageAccount $storageAccount -type $type -version $versionno -select All -accept_insiderEula | ForEach-Object {
2020-09-02 18:07:29 +03:00
$countries + = $_ . SubString ( $_ . LastIndexOf ( '/' ) +1 ) . Split ( '?' ) [ 0 ]
}
2020-07-21 15:27:36 +03:00
$description = " "
if ( $version -ne " " ) {
$description + = " Version $version selected `n `n "
}
2020-09-02 18:07:29 +03:00
else {
$description + = " Version $versionno identified `n `n "
}
2020-07-13 16:27:37 +03:00
if ( $type -eq " Sandbox " ) {
$default = " us "
2020-07-21 15:27:36 +03:00
$description + = " Please select which country version you want to use. `n `n Note: base is the onprem w1 demodata running in sandbox mode. "
2020-07-13 16:27:37 +03:00
}
else {
$default = " w1 "
2020-07-21 15:27:36 +03:00
$description + = " Please select which country version you want to use. `n `n Note: NA contains US, CA and MX. "
2020-07-03 14:39:00 +03:00
}
2020-07-03 09:42:26 +03:00
2020-07-03 14:39:00 +03:00
2020-07-13 16:27:37 +03:00
$country = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_____ _
/ ____ | | |
| | ___ _ _ _ __ | | _ _ __ _ _
| | / _ \ | | | | '_ \| __| ' __ | | | |
| | ____ ( _ ) | | _ | | | | | | _ | | | | _ | |
\ _____ \ ___ / \ __ , _ | _ | | _ | \ __ | _ | \ __ , |
__ / |
| ___ /
' @ `
2020-07-13 16:27:37 +03:00
-description $description `
-options $countries `
-default $default `
-question " Country " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-05 13:36:20 +03:00
}
2020-07-03 09:42:26 +03:00
2020-09-02 18:07:29 +03:00
$Step . TestToolkit {
2020-07-21 15:27:36 +03:00
2021-04-03 10:40:14 +03:00
if ( $majorVersion -ge 18 ) {
$licenseNote = " Full Test Toolkit requires a license in order to be used "
}
else {
$licenseNote = " Test Libraries requires a license in order to be used "
}
2020-07-15 01:49:02 +03:00
$testtoolkit = Select-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_______ _ _______ _ _ _ _
| __ __ | | | | __ __ | | | | ( _ ) |
| | ___ ___ | | _ | | ___ ___ | | | ___ | | _
| | / _ \ __ | __ | | | / _ \ / _ \ | | | / / | __ |
| | __ \ __ \ | _ | | ( _ ) | ( _ ) | | < | | | _
| _ | \ ___ | ___ / \ __ | | _ | \ ___ / \ ___ / | _ | _ | \ _ \ _ | \ __ |
' @ `
2021-04-03 10:40:14 +03:00
-description " Do you need the test toolkit to be installed? `n The Test Toolkit is needed in order to develop and run tests in the container. `n `n Note: $licenseNote " `
2020-07-15 01:49:02 +03:00
-options ( [ ordered ] @ { " All " = " Full Test Toolkit (Test Framework, Test Libraries and Microsoft tests) " ; " Libraries " = " Test Framework and Test Libraries " ; " Framework " = " Test Framework " ; " No " = " No Test Toolkit needed " } ) `
-question " Test Toolkit " `
-default " No " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-06 14:22:50 +03:00
}
2020-09-02 18:07:29 +03:00
$Step . PerformanceToolkit {
$performanceToolkit = " N "
if ( $majorVersion -ge 17 -and $testtoolkit -ne " No " ) {
$performancetoolkit = Enter-Value `
-title @ '
_____ __ _______ _ _ _ _
| __ \ / _ | | __ __ | | | | ( _ ) |
| | __ ) | __ _ __ | | _ ___ _ __ _ __ ___ __ _ _ __ ___ ___ | | ___ ___ | | | ___ | | _
| ___ / _ \ '__| _/ _ \| ' __ | '_ ` _ \ / _` | ' _ \ / __ / _ \ | | / _ \ / _ \ | | | / / | __ |
| | | __ / | | | | ( _ ) | | | | | | | | ( _ | | | | | ( __ __ / | | ( _ ) | ( _ ) | | < | | | _
| _ | \ ___ | _ | | _ | \ ___ / | _ | | _ | | _ | | _ | \ __ , _ | _ | | _ | \ ___ \ ___ | | _ | \ ___ / \ ___ / | _ | _ | \ _ \ _ | \ __ |
' @ `
-description " The Performance Toolkit ships with Business Central 17.0. `n `n Do you need the performance toolkit to be installed? `n The Performance Toolkit is needed in order to develop and run performance tests in the container. " `
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you want to install the performance toolkit " `
-default " N " `
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
}
}
2020-07-21 15:27:36 +03:00
$Step . PremiumPlan {
2020-07-13 16:27:37 +03:00
$assignPremiumPlan = " N "
if ( $type -eq " Sandbox " ) {
if ( $hosting -eq " local " ) { $back = 8 } else { $back = 7 }
$assignPremiumPlan = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_____ _ _____ _
| __ \ ( _ ) | __ \ | |
| | __ ) | __ ___ _ __ ___ _ _ _ _ __ ___ | | __ ) | | __ _ _ __
| ___ / '__/ _ \ ' _ ` _ \ | | | | | '_ ` _ \ | ___/| |/ _` | ' _ \
| | | | | __ / | | | | | | | _ | | | | | | | | | | | ( _ | | | | |
| _ | | _ | \ ___ | _ | | _ | | _ | _ | \ __ , _ | _ | | _ | | _ | | _ | | _ | \ __ , _ | _ | | _ |
' @ `
2020-07-13 16:27:37 +03:00
-Description " When running sandbox, you can select to assign premium plan to the users. " `
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you want to assign premium plan " `
-default " N " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-06 14:22:50 +03:00
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 14:39:00 +03:00
2020-08-24 20:30:52 +03:00
$step . IncludeAL {
$includeAL = " N "
2023-01-29 12:55:55 +03:00
if ( $hosting -eq 'local' -and $majorVersion -gt 14 ) {
2020-08-24 20:30:52 +03:00
$includeAL = Enter-Value `
-title @ '
_ ____ _____ _ _
/ \ | | | _ \ / \ | __ \ | | | |
/ \ | | | | _ ) | __ _ ___ ___ / \ _ __ _ __ | | | | _____ _____ | | ___ _ __ _ __ ___ ___ _ __ | | _
/ / \ \ | | | _ < / _ ` / __ | / _ \ / / \ \ | '_ \| ' _ \ | | | | / _ \ \ / / _ \ | / _ \ | '_ \| ' _ ` _ \ / _ \ ' _ \ | __ |
/ ____ \ | | ____ | | _ ) | ( _ | \ __ \ __ / / ____ \ | | _ ) | | _ ) | | | __ | | __ / \ V / __ / | ( _ ) | | _ ) | | | | | | __ / | | | | _
/ _ / \ _ \ ______ | | ____ / \ __ , _ | ___ / \ ___ | / _ / \ _ \ . __ / | . __ / | _____ / \ ___ | \ _ / \ ___ | _ | \ ___ / | . __ / | _ | | _ | | _ | \ ___ | _ | | _ | \ __ |
| | | | | |
| _ | | _ | | _ |
' @ `
2020-09-03 17:46:51 +03:00
-Description " If you are going to perform base app development (modify and publish the base application), you will need to use an option called -includeAL. `n `n This option is not needed if you are going to write extensions only. " `
2020-08-24 20:30:52 +03:00
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you need to do base app development " `
-default " N " `
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
}
}
$step . ExportAlSource {
$exportAlSource = " N "
if ( $includeAL -eq " Y " ) {
$exportALSource = Enter-Value `
-title @ '
______ _ _ ____
| ____ | | | / \ | | | _ \ / \
| | __ __ ___ __ ___ _ __ | | _ / \ | | | | _ ) | __ _ ___ ___ / \ _ __ _ __
| __ | \ \ / / '_ \ / _ \| ' __ | __ | / / \ \ | | | _ < / _ ` / __ | / _ \ / / \ \ | '_ \| ' _ \
| | ____ > < | | _ ) | ( _ ) | | | | _ / ____ \ | | ____ | | _ ) | ( _ | \ __ \ __ / / ____ \ | | _ ) | | _ ) |
| ______ / _ / \ _ \ . __ / \ ___ / | _ | \ __ | / _ / \ _ \ ______ | | ____ / \ __ , _ | ___ / \ ___ | / _ / \ _ \ . __ / | . __ /
| | | | | |
| _ | | _ | | _ |
' @ `
-Description " When specifying -includeAL, the default behavior is to export the AL source code as a project for you to modify, compile and publish. `n If you already have a source code repository this is obviously not needed and can be avoided by specifying an option called -doNotExportObjectsToText. `n `n Do you want to export the Base App as an AL source code project? " `
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you want to export the base app AL source code " `
-default " N " `
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
}
}
$step . IncludeCSIDE {
$includeCSIDE = " N "
2020-09-02 18:07:29 +03:00
2023-01-29 12:55:55 +03:00
if ( $hosting -eq 'local' -and $majorVersion -le 14 ) {
2020-08-24 20:30:52 +03:00
if ( $majorVersion -lt 14 ) {
$product = " NAV "
}
else {
$product = " a version of Business Central "
}
$includeCSIDE = Enter-Value `
-title @ '
_____ __ _ _____ _ _
/ ____ | / / \ | | | __ \ | | | |
| | / / \ | | | | | | _____ _____ | | ___ _ __ _ __ ___ ___ _ __ | | _
| | / / / \ \ | | | | | | / _ \ \ / / _ \ | / _ \ | '_ \| ' _ ` _ \ / _ \ ' _ \ | __ |
| | ____ / / ____ \ | | ____ | | __ | | __ / \ V / __ / | ( _ ) | | _ ) | | | | | | __ / | | | | _
\ _____ / _ / _ / \ _ \ ______ | | _____ / \ ___ | \ _ / \ ___ | _ | \ ___ / | . __ / | _ | | _ | | _ | \ ___ | _ | | _ | \ __ |
| |
| _ |
' @ `
2020-09-03 17:46:51 +03:00
-Description " You are running $product , which includes the legacy Windows Client and legacy C/AL development. `n If you are going to use the Windows Client or use C/AL development, you will need to use an option called -includeCSIDE. " `
2020-08-24 20:30:52 +03:00
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you need CSIDE or Windows Client " `
-default " N " `
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
}
}
$step . ExportCAlSource {
$exportCAlSource = " N "
if ( $includeCSIDE -eq " Y " ) {
$exportCAlSource = Enter-Value `
-title @ '
______ _ _____ __ _ ____
| ____ | | | / ____ | / / \ | | | _ \ / \
| | __ __ ___ __ ___ _ __ | | _ | | / / \ | | | | _ ) | __ _ ___ ___ / \ _ __ _ __
| __ | \ \ / / '_ \ / _ \| ' __ | __ | | | / / / \ \ | | | _ < / _ ` / __ | / _ \ / / \ \ | '_ \| ' _ \
| | ____ > < | | _ ) | ( _ ) | | | | _ | | ____ / / ____ \ | | ____ | | _ ) | ( _ | \ __ \ __ / / ____ \ | | _ ) | | _ ) |
| ______ / _ / \ _ \ . __ / \ ___ / | _ | \ __ | \ _____ / _ / _ / \ _ \ ______ | | ____ / \ __ , _ | ___ / \ ___ | / _ / \ _ \ . __ / | . __ /
| | | | | |
| _ | | _ | | _ |
' @ `
-Description " When specifying -includeCSIDE, the default behavior is to export the C/AL source code as text files. `n If you already have a source code repository this is obviously not needed and can be avoided by specifying an option called -doNotExportObjectsToText. `n `n Do you want to export the C/AL base app as text files? " `
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you want to export the C/AL base app as text files " `
-default " N " `
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
}
}
2020-09-03 17:46:51 +03:00
$Step . Vsix {
$vsix = " N "
2023-01-29 12:55:55 +03:00
if ( $hosting -eq 'local' -and $majorVersion -gt 14 ) {
2020-09-03 17:46:51 +03:00
$vsix = Enter-Value `
-title @ '
_ _ ______ _ _
/ \ | | | | | ____ | | | ( _ )
/ \ | | | | __ _ _ __ __ _ _ _ __ _ __ _ ___ | | __ __ __ | _ ___ _ __ ___ _ ___ _ __
/ / \ \ | | | | / _ ` | '_ \ / _` | | | |/ _` |/ _` |/ _ \ | __| \ \/ / __/ _ \ ' _ \ / __ | | / _ \ | ' _ \
/ ____ \ | | ____ | | ____ ( _ | | | | | ( _ | | | _ | | ( _ | | ( _ | | __ / | | ____ > < | | _ __ / | | \ __ \ | ( _ ) | | | |
/ _ / \ _ \ ______ | | ______ \ __ , _ | _ | | _ | \ __ , | \ __ , _ | \ __ , _ | \ __ , | \ ___ | | ______ / _ / \ _ \ \ __ \ ___ | _ | | _ | ___ / _ | \ ___ / | _ | | _ |
__ / | __ / |
| ___ / | ___ /
' @ `
-description " The AL language extension used in the container is normally the vsix file that comes with the version of Business Central selected. `n `n You can select to use the latest shipped AL Language extension from the marketplace by specifying -vsixFile <url>. " `
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you want to use the latest AL Language extension from the marketplace " `
-default " N " `
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
}
}
2020-07-21 15:27:36 +03:00
$Step . CreateTestUsers {
2020-07-13 16:27:37 +03:00
$createTestUsers = " N "
if ( $type -eq " Sandbox " ) {
2020-07-21 15:27:36 +03:00
2020-07-13 16:27:37 +03:00
$createTestUsers = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_____ _ _______ _ _ _
/ ____ | | | | __ __ | | | | | | |
| | _ __ ___ __ _ | | _ ___ | | ___ ___ | | _ | | | | ___ ___ _ __ ___
| | | '__/ _ \/ _` | __/ _ \ | |/ _ \ __| __| | | | / __|/ _ \ ' __ / __ |
| | ____ | | | __ / ( _ | | | _ __ / | | __ \ __ \ | _ | | __ | \ __ \ __ / | \ __ \
\ _____ | _ | \ ___ | \ __ , _ | \ __ \ ___ | | _ | \ ___ | ___ / \ __ | \ ____ / | ___ / \ ___ | _ | | ___ /
' @ `
2020-07-13 16:27:37 +03:00
-Description " When running sandbox, you can select to add test users with special entitlements. `n The users created are: ExternalAccountant, Premium, Essential, InternalAdmin, TeamMember and DelegatedAdmin. `n `n Note: This requires a license file to be specified. " `
-options @ ( " Y " , " N " ) `
-question " Please enter Y if you want to create test users " `
-default " N " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-05 10:04:43 +03:00
}
2020-07-13 16:27:37 +03:00
}
2020-07-04 10:07:32 +03:00
2020-07-21 15:27:36 +03:00
$Step . License {
2021-04-03 10:40:14 +03:00
if ( $majorVersion -ge 18 ) {
$licenserequired = ( $testtoolkit -eq " All " -or $createTestUsers -eq " Y " -or $exportCAlSource -eq " Y " -or $exportAlSource -eq " Y " )
}
else {
$licenserequired = ( $testtoolkit -eq " All " -or $testtoolkit -eq " Libraries " -or $performanceToolkit -eq " Y " -or $createTestUsers -eq " Y " -or $exportCAlSource -eq " Y " -or $exportAlSource -eq " Y " )
}
2020-07-13 16:27:37 +03:00
if ( $licenserequired ) {
$description = " Please specify a license file url. `n Due to other selections, you need to specify a license file. "
$default = " "
2020-07-05 10:04:43 +03:00
}
2020-07-13 16:27:37 +03:00
else {
$description = " Please specify a license file url. `n If you do not specify a license file, you will use the default Cronus Demo License. "
$default = " blank "
2020-07-05 10:04:43 +03:00
}
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
$description + = " `n `n This can be a local file or a secure direct download url (see https://freddysblog.com/2017/02/26/create-a-secure-url-to-a-file/) "
2020-07-05 10:04:43 +03:00
}
else {
2020-07-13 16:27:37 +03:00
$description + = " `n `n This needs to be a secure direct download url (see https://freddysblog.com/2017/02/26/create-a-secure-url-to-a-file/) "
2020-07-05 10:04:43 +03:00
}
2020-07-13 16:27:37 +03:00
$licenseFile = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_ _
| | ( _ )
| | _ ___ ___ _ __ ___ ___
| | | | / __ / _ \ ' _ \ / __ | / _ \
| | ____ | | ( __ __ / | | \ __ \ __ /
| ______ | _ | \ ___ \ ___ | _ | | _ | ___ / \ ___ |
' @ `
2020-07-05 10:04:43 +03:00
-description $description `
2020-07-13 16:27:37 +03:00
-question " License File " `
-default $default `
2020-09-30 05:14:27 +03:00
-previousStep `
-doNotConvertToLower
2020-07-21 15:27:36 +03:00
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-13 16:27:37 +03:00
if ( $licenseFile -eq " blank " ) {
$licenseFile = " "
2020-07-13 02:30:04 +03:00
}
else {
2020-07-13 16:27:37 +03:00
$licenseFile = $licenseFile . Trim ( @ ( '"' ) )
2020-07-13 02:30:04 +03:00
}
2020-07-13 16:27:37 +03:00
}
2020-07-13 02:30:04 +03:00
2020-07-21 15:27:36 +03:00
$Step . Database {
2023-01-29 12:55:55 +03:00
if ( $hosting -ne " Local " ) {
$database = " default "
}
else {
$database = Select-Value `
-title @ '
2020-07-21 15:27:36 +03:00
_____ _ _
| __ \ | | | |
| | | | __ _ | | _ __ _ | | __ __ _ ___ ___
| | | | / _ ` | __ / _ ` | ' _ \ / _ ` / __ | / _ \
| | __ | | ( _ | | | _ ( _ | | | _ ) | ( _ | \ __ \ __ /
| _____ / \ __ , _ | \ __ \ __ , _ | _ . __ / \ __ , _ | ___ / \ ___ |
' @ `
2023-01-29 12:55:55 +03:00
-description " When running Business Central on Docker the default behavior is to run the Cronus Demo database inside the container, using the instance of SQLEXPRESS, which is installed there. `n You can change the database by specifying a database backup or you can configure the container to connect to a database server (which might be on the host). " `
-options ( [ ordered ] @ { " default " = " Use Cronus demo database on SQLEXPRESS inside the container " ; " bakfile " = " Restore a database backup on SQLEXPRESS inside the container (must be the correct version) " ; " connect " = " Connect to an existing database on a database server (which might be on the host) " } ) `
-question " Database " `
-default " default " `
2020-07-21 15:27:36 +03:00
-previousStep
2023-01-29 12:55:55 +03:00
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-13 16:27:37 +03:00
2023-01-29 12:55:55 +03:00
if ( $database -eq " bakfile " ) {
$bakFile = Enter-Value `
-title " Database Backup " `
-description " Please specify the full path and filename of the database backup (.bak file) you want to use. `n `n Note: The database backup must be from the same version as the version running in the container " `
-question " Database Backup " `
2020-07-21 15:27:36 +03:00
-previousStep
2023-01-29 12:55:55 +03:00
$bakFile = $bakFile . Trim ( @ ( '"' ) )
}
elseif ( $database -eq " connect " ) {
$err = $false
do {
$params = @ { }
2020-07-13 16:27:37 +03:00
if ( $err ) {
2023-01-29 12:55:55 +03:00
$params = @ { " doNotClearHost " = $true }
2020-07-13 02:30:04 +03:00
}
2023-01-29 12:55:55 +03:00
$connectionString = Enter-Value @params `
-title " Database Connection String " `
-description " Please enter the connection string for your database connection. `n `n Format: Server|Data Source=myServerName\myServerInstance;Database|Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword `n `n Note: Specify localhost or . as myServerName if the database server is the host. `n Note: The connection string cannot use integrated security, it must include username and password. " `
-question " Database Connection String " `
-doNotConvertToLower `
-previousStep
if ( $connectionString -eq " back " ) {
$err = $false
}
else {
$databaseServer = $connectionString . Split ( ';' ) | Where-Object { $_ -like " Server=* " -or $_ -like " Data Source=* " } | % { $_ . SubString ( $_ . indexOf ( '=' ) +1 ) }
$databaseName = $connectionString . Split ( ';' ) | Where-Object { $_ -like " Database=* " -or $_ -like " Initial Catalog=* " } | % { $_ . SubString ( $_ . indexOf ( '=' ) +1 ) }
$databaseUserName = $connectionString . Split ( ';' ) | Where-Object { $_ -like " User Id=* " } | % { $_ . SubString ( $_ . indexOf ( '=' ) +1 ) }
$databasePassword = $connectionString . Split ( ';' ) | Where-Object { $_ -like " Password=* " } | % { $_ . SubString ( $_ . indexOf ( '=' ) +1 ) }
$err = ! ( ( $databaseServer ) -and ( $databaseName ) -and ( $databaseUserName ) -and ( $databasePassword ) )
if ( $err ) {
Write-Host -ForegroundColor Red " You need to specify a connection string, which contains all 4 elements described "
Write-Host
}
}
} while ( $err )
if ( $connectionString -ne " back " ) {
$idx = $databaseServer . IndexOf ( '\' )
if ( $idx -ge 0 ) {
$databaseInstance = $databaseServer . Substring ( $idx + 1 )
$databaseServer = $databaseServer . Substring ( 0 , $idx )
}
else {
$databaseInstance = " "
}
if ( $databaseServer -eq " " -or $databaseServer -eq " . " -or $databaseServer -eq " localhost " ) {
$databaseServer = " host.containerhelper.internal "
}
$databaseName = $databaseName . TrimStart ( '[' ) . TrimEnd ( ']' )
2020-07-13 02:30:04 +03:00
}
}
}
2020-07-13 16:27:37 +03:00
}
2020-07-13 02:30:04 +03:00
2020-08-24 20:30:52 +03:00
$step . Multitenant {
2023-01-29 12:55:55 +03:00
if ( $database -ne " Connect " -and $hosting -eq 'local' ) {
2020-08-24 20:30:52 +03:00
if ( $type -eq " Sandbox " ) {
$description = " You are running a sandbox container, which by default is multitenant. `n By specifying -multitenant: `$ false, you can switch the container to single tenancy. "
$default = " Y "
}
else {
$description = " You are running an onprem container, which by default is singletenant. `n By specifying -multitenant, you can switch the container to multitenant. "
$default = " N "
}
$multitenant = Enter-Value `
-title @ '
__ __ _ _ _ _ _
| \ / | | | | ( _ ) | | |
| \ / | _ _ | | | _ _ | | _ ___ _ __ __ _ _ __ | | _
| | \ / | | | | | | __ | | __ / _ \ '_ \ / _` | ' _ \ | __ |
| | | | | _ | | | | _ | | | _ __ / | | | ( _ | | | | | | _
| _ | | _ | \ __ , _ | _ | \ __ | _ | \ __ \ ___ | _ | | _ | \ __ , _ | _ | | _ | \ __ |
' @ `
-description $description `
-options @ ( " Y " , " N " ) `
-question " Please select Y if you want a multitenant container " `
-default $default `
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
if ( $multitenant -eq $default ) {
$multitenant = " "
}
}
}
2020-07-21 15:27:36 +03:00
$Step . DNS {
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
2020-07-21 15:27:36 +03:00
2020-07-13 16:27:37 +03:00
$options = [ ordered ] @ { " default " = " Use default DNS settings (configured in Docker Daemon) " ; " usegoogledns " = " Add Google public dns (8.8.8.8) as DNS to the container " }
2022-07-26 12:42:36 +03:00
$hostDNS = @ ( Get-NetIPInterface | Where-Object { $_ . ConnectionState -eq " Connected " -and $_ . AddressFamily -eq " IPv4 " } | ForEach-Object { Get-DnsClientServerAddress -AddressFamily IPv4 -InterfaceAlias $_ . InterfaceAlias | ForEach-Object { $_ . ServerAddresses } } ) -join ','
2020-07-13 16:27:37 +03:00
if ( $hostDNS ) {
2022-07-26 12:42:36 +03:00
$options + = @ { " usehostdns " = " Add your hosts DNS servers ( $hostDNS ) as DNS to the container " }
2020-07-13 16:27:37 +03:00
}
$dns = Select-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_____ _ _ _____
| __ \ | \ | | / ____ |
| | | | \ | | ( ___
| | | | . ` | \ ___ \
| | __ | | | \ | ____ ) |
| _____ / | _ | \ _ | _____ /
' @ `
2020-07-13 16:27:37 +03:00
-description " On some networks, default DNS resolution does not work inside a running container. `n When this is the case, you will see a warning during start saying: `n `n WARNING: DNS resolution not working from within the container. `n `n Some times, this can be fixed by choosing a different DNS server. Some times you have to reconfigure your network or antivirus settings to allow this. " `
-options $options `
-question " Use DNS " `
-default " default " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-13 02:30:04 +03:00
}
2020-07-13 16:27:37 +03:00
}
2020-07-13 02:30:04 +03:00
2020-08-10 16:04:51 +03:00
$Step . SSL {
if ( $hosting -eq " Local " ) {
$options = [ ordered ] @ { " default " = " Do not use SSL (use http) " ; " usessl " = " Use SSL (https) with self-signed certificate " ; " usessl2 " = " Use SSL (https) with self-signed certificate and install certificate on host computer " }
$ssl = Select-Value `
-title @ '
_____ _____ _
/ ____ / ____ | |
| ( ___ | ( ___ | |
\ ___ \ \ ___ \ | |
____ ) | ___ ) | | ____
| _____ / _____ / | ______ |
' @ `
-description " If your container is only used from host computer, you likely do not need to setup SSL. There are however functionality (like camera), which requires SSL and will not work if you haven't setup SSL. `n Installing the self-signed certificate on the host might remove some of the insecure connection warnings from your browser. " `
-options $options `
-question " Use SSL " `
-default " default " `
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
}
}
2020-07-21 15:27:36 +03:00
$Step . Isolation {
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
2020-07-21 15:27:36 +03:00
2020-07-13 16:27:37 +03:00
$os = ( Get-CimInstance Win32_OperatingSystem )
if ( $os . OSType -ne 18 -or ! $os . Version . StartsWith ( " 10.0. " ) ) {
throw " Unknown Host Operating System "
}
2020-07-13 02:30:04 +03:00
2020-07-13 16:27:37 +03:00
$UBR = ( Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name UBR ) . UBR
$hostOsVersion = [ System.Version ] :: Parse ( " $( $os . Version ) . $UBR " )
try {
$bestContainerOS = " The image, which matches your host OS best is $( $bestContainerOsVersion . ToString ( ) ) "
2022-11-28 07:43:11 +03:00
if ( $hostOsVersion . Build -ge 20348 -and $bestContainerOsVersion . Build -ge 20348 ) {
if ( $bestContainerOsVersion -le $hostOsVersion ) {
$defaultIsolation = " process "
}
else {
$defaultIsolation = " Hyper-V "
}
}
elseif ( $hostOsVersion . Major -eq $bestContainerOsVersion . Major -and $hostOsVersion . Minor -eq $bestContainerOsVersion . Minor -and $hostOsVersion . Build -eq $bestContainerOsVersion . Build ) {
2020-07-13 16:27:37 +03:00
$defaultIsolation = " Process "
}
else {
$defaultIsolation = " Hyper-V "
}
}
catch {
$bestContainerOsVersion = [ System.Version ] " 0.0.0.0 "
$bestContainerOS = " Unable to determine the image which matches your OS best "
$defaultIsolation = " Hyper-V "
}
$description = " Containers can run in process isolation or hyperv isolation, see more here: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/hyperv-container `n If not specified, the ContainerHelper will try to detect which isolation mode will work for your OS. `n If an image with a matching OS is found, Process isolation will be favoured, else Hyper-V will be selected. `n `n Your host OS is Windows $( $hostOSVersion . ToString ( ) ) `n $bestContainerOS `n "
2020-07-06 14:22:50 +03:00
2020-07-13 16:27:37 +03:00
if ( $isAdministrator ) {
2022-04-16 09:18:36 +03:00
$hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper -V -Online
2020-07-13 16:27:37 +03:00
if ( $hyperv ) {
$description + = " Hyper-V is enabled "
}
else {
$description + = " Hyper-V is NOT enabled (you will not be able to use Hyper-V isolation on this host) "
$defaultIsolation = " Process "
}
}
$options = [ ordered ] @ { " default " = " Allow the ContainerHelper to decide which isolation mode to use (on this host, this will be $defaultIsolation isolation) " ; " process " = " Force Process isolation " ; " hyperv " = " Force Hyper-V isolation " }
2020-07-04 10:07:32 +03:00
2020-07-13 16:27:37 +03:00
$isolation = Select-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_____ _ _ _
| _ _ | | | | | ( _ )
| | ___ ___ | | __ _ | | _ _ ___ _ __
| | / __ | / _ \ | | / _ ` | __ | | / _ \ | ' _ \
_ | | _ \ __ \ ( _ ) | | ( _ | | | _ | | ( _ ) | | | |
| _____ | ___ / \ ___ / | _ | \ __ , _ | \ __ | _ | \ ___ / | _ | | _ |
' @ `
2020-07-13 16:27:37 +03:00
-description $description `
-options $options `
-question " Isolation " `
-default " default " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 14:39:00 +03:00
}
2020-07-21 15:27:36 +03:00
$Step . Memory {
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
2020-07-21 15:27:36 +03:00
2020-07-13 16:27:37 +03:00
$demo = 4
$development = 8
2020-08-24 20:30:52 +03:00
if ( $majorVersion -ge 16 ) {
2020-07-13 16:27:37 +03:00
$newBaseApp = 16
}
elseif ( $majorVersion -eq 15 ) {
$newBaseApp = 12
2020-07-05 11:09:50 +03:00
}
else {
2020-07-13 16:27:37 +03:00
$newBaseApp = 0
2020-07-05 11:09:50 +03:00
}
2020-07-13 16:27:37 +03:00
$description = " The amount of memory needed by the container depends on what you are going to use it for. `n `n Typical memory consumption for this version of Business Central are: `n - $( $demo ) G for demo/test usage of Business Central `n - $( $demo ) G- $( $development ) G for app development `n "
if ( $newBaseApp ) {
$description + = " - $( $newBaseApp ) G for base app development `n "
2020-07-03 09:42:26 +03:00
}
2020-07-13 16:27:37 +03:00
if ( $isolation -eq " process " -or ( $isolation -eq " default " -and $defaultIsolation -eq " Process " ) ) {
$description + = " `n When running Process isolation, the container will only use the actual amount of memory used by the processes running in the container from the host. `n Memory no longer needed by the processes in the container are given back to the host `n You can set a limit to the amount of memory, the container is allowed to use. "
$defaultDescription = " blank means no limit "
}
else {
$description + = " `n When running Hyper-V isolation, the container will pre-allocate the full amount of memory given to the container. `n "
if ( $hostOsVersion . Build -ge 17763 ) {
$description + = " Windows Server 2019 / Windows 10 1809 and later Windows versions are doing this by reserving the memory in the paging file and only using physical memory when needed. `n Memory no longer needed will be freed from physical memory again. `n "
try {
$CompSysResults = Get-CimInstance win32_computersystem -ComputerName $computer -Namespace 'root\cimv2'
if ( $CompSysResults . AutomaticManagedPagefile ) {
$description + = " Your paging file settings indicate that your paging file is automatically managed, you could consider changing this if you get problems with the size of the paging file. `n "
}
}
catch { }
}
else {
$description + = " Windows Server 2016 and Windows 10 versions before 1809 is doing this by allocating the memory from the main memory pool. `n "
}
$defaultDescription = " blank will use ContainerHelper default which is 4G "
}
$memoryLimit = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
__ __ _ _ _ _
| \ / | | | ( _ ) ( _ ) |
| \ / | ___ _ __ ___ ___ _ __ _ _ | | _ _ __ ___ _ | | _
| | \ / | | / _ \ '_ ` _ \ / _ \| ' __ | | | | | | | | ' _ ` _ \ | | __ |
| | | | __ / | | | | | ( _ ) | | | | _ | | | | ____ | | | | | | | | | _
| _ | | _ | \ ___ | _ | | _ | | _ | \ ___ / | _ | \ __ , | | ______ | _ | _ | | _ | | _ | _ | \ __ |
__ / |
| ___ /
' @ `
2020-07-13 16:27:37 +03:00
-description $description `
-question " Specify the amount of memory the container is allowed to use? ( $defaultDescription ) " `
-default 'blank' `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-13 16:27:37 +03:00
if ( $memoryLimit -eq " blank " ) {
$memoryLimit = " "
}
else {
$memoryLimit = " $( $memoryLimit . Trim ( ) . ToLowerInvariant ( ) . TrimEnd ( 'gb' ) . TrimEnd ( 'g' ) ) G "
2020-07-03 09:42:26 +03:00
}
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 09:42:26 +03:00
2020-07-21 15:27:36 +03:00
$Step . SaveImage {
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
$imageName = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_____ _
/ ____ | ( _ )
| ( ___ __ ___ _____ _ _ __ ___ __ _ __ _ ___
\ ___ \ / _ ` \ \ / / _ \ | | ' _ ` _ \ / _ ` | / _ ` | / _ \
____ ) | ( _ | | \ V / __ / | | | | | | | ( _ | | ( _ | | __ /
| _____ / \ __ , _ | \ _ / \ ___ | | _ | _ | | _ | | _ | \ __ , _ | \ __ , | \ ___ |
__ / |
| ___ /
' @ `
2020-07-13 16:27:37 +03:00
-description " If you are planning on running the same script multiple times, it will save time on subsequent runs to save the image `n The ContainerHelper will automatically generate an image tag, matching the version number and country of the requested version and on every run it will check whether the image needs to be rebuild. `n `n Recommendation is to use a short name (like mybcimage) if you want to save the image. " `
-question " Image name (or blank to skip saving) " `
-default " blank " `
2020-07-21 15:27:36 +03:00
-previousStep
if ( $script:wizardStep -eq $script:thisStep + 1 ) {
$script:prevSteps . Push ( $script:thisStep )
}
2020-07-05 10:04:43 +03:00
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 09:42:26 +03:00
2020-07-21 15:27:36 +03:00
$Step . Special {
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
2020-08-21 14:17:56 +03:00
2020-07-13 16:27:37 +03:00
# TODO: Publish ports
2020-09-03 17:46:51 +03:00
# TODO: Options like CheckHealth, Restart, Locale, TimeZoneId, Timeout
2020-07-13 16:27:37 +03:00
2020-07-03 14:39:00 +03:00
}
2020-07-13 16:27:37 +03:00
}
2020-07-03 14:39:00 +03:00
2020-07-21 15:27:36 +03:00
# ______ _ _
# | ____(_) | |
# | |__ _ _ __ __ _| |
# | __| | | '_ \ / _` | |
# | | | | | | | (_| | |
# |_| |_|_| |_|\__,_|_|
#
$step . Final {
2020-07-15 12:22:08 +03:00
$script:acceptDefaults = $false
2020-07-13 16:27:37 +03:00
if ( $hosting -eq " Local " ) {
2020-07-21 15:27:36 +03:00
2020-07-13 16:27:37 +03:00
$parameters = @ ( )
$script = @ ( )
$script + = " `$ containerName = ' $containerName ' "
if ( $auth -eq " UserPassword " ) {
$script + = " `$ credential = Get-Credential -Message 'Using UserPassword authentication. Please enter credentials for the container.' "
2020-07-05 10:04:43 +03:00
}
2020-07-13 16:27:37 +03:00
elseif ( $auth -eq " Windows " ) {
$script + = " `$ credential = Get-Credential -Message 'Using Windows authentication. Please enter your Windows credentials for the host computer.' "
}
else
{
if ( $auth -eq " Credential " ) {
$script + = " `$ password = ' $predefinedpw ' "
}
else {
$script + = " `$ password = ' $randompw ' "
}
$script + = " `$ securePassword = ConvertTo-SecureString -String `$ password -AsPlainText -Force "
$script + = " `$ credential = New-Object pscredential 'admin', `$ securePassword "
$auth = " UserPassword "
}
$parameters + = " -credential `$ credential "
$script + = " `$ auth = ' $auth ' "
$parameters + = " -auth `$ auth "
2020-09-02 18:07:29 +03:00
2020-09-03 17:46:51 +03:00
if ( $nav ) {
if ( $cu -eq " latest " ) {
$script + = " `$ artifactUrl = Get-NavArtifactUrl -nav ' $nav ' -country ' $country ' "
}
else {
$script + = " `$ artifactUrl = Get-NavArtifactUrl -nav ' $nav ' -cu ' $cu ' -country ' $country ' "
}
}
elseif ( $predef -like " Next* " ) {
2023-09-27 16:09:36 +03:00
$script + = " `$ artifactUrl = Get-BcArtifactUrl -storageAccount ' $storageAccount ' -type ' $type ' -country ' $country ' -select ' $select ' -accept_insiderEula "
$parameters + = " -accept_insiderEula "
2020-09-02 18:07:29 +03:00
}
else {
if ( $version ) {
$script + = " `$ artifactUrl = Get-BcArtifactUrl -type ' $type ' -version ' $version ' -country ' $country ' -select ' $select ' "
}
else {
$script + = " `$ artifactUrl = Get-BcArtifactUrl -type ' $type ' -country ' $country ' -select ' $select ' "
}
}
2020-07-13 16:27:37 +03:00
$parameters + = " -artifactUrl `$ artifactUrl "
if ( $imageName -ne " blank " ) {
$parameters + = " -imageName ' $( $imageName . ToLowerInvariant ( ) ) ' "
}
if ( $database -eq " bakfile " ) {
$script + = " `$ bakFile = ' $bakFile ' "
$parameters + = " -bakFile `$ bakFile "
}
elseif ( $database -eq " connect " ) {
$script + = " `$ databaseServer = ' $databaseServer ' "
$script + = " `$ databaseInstance = ' $databaseInstance ' "
$script + = " `$ databaseName = ' $databaseName ' "
$script + = " `$ databaseUsername = ' $databaseUsername ' "
$script + = " `$ databasePassword = ' $databasePassword ' "
$script + = " `$ databaseSecurePassword = ConvertTo-SecureString -String `$ databasePassword -AsPlainText -Force "
$script + = " `$ databaseCredential = New-Object pscredential `$ databaseUsername, `$ databaseSecurePassword "
$parameters + = " -databaseServer `$ databaseServer -databaseInstance `$ databaseInstance -databaseName `$ databaseName "
$parameters + = " -databaseCredential `$ databaseCredential "
}
2020-08-24 20:30:52 +03:00
if ( $multitenant -eq " Y " ) {
$parameters + = " -multitenant "
}
elseif ( $multitenant -eq " N " ) {
$parameters + = " -multitenant: `$ false "
}
2020-07-13 16:27:37 +03:00
if ( $testtoolkit -ne " No " ) {
$parameters + = " -includeTestToolkit "
if ( $testtoolkit -eq " Framework " ) {
$parameters + = " -includeTestFrameworkOnly "
}
elseif ( $testtoolkit -eq " Libraries " ) {
$parameters + = " -includeTestLibrariesOnly "
}
2020-09-02 18:07:29 +03:00
if ( $performanceToolkit -eq " Y " ) {
$parameters + = " -includePerformanceToolkit "
}
2020-07-13 16:27:37 +03:00
}
if ( $assignPremiumPlan -eq " Y " ) {
$parameters + = " -assignPremiumPlan "
}
if ( $licenseFile ) {
$script + = " `$ licenseFile = ' $licenseFile ' "
$parameters + = " -licenseFile `$ licenseFile "
}
if ( $dns -eq " usegoogledns " ) {
$parameters + = " -dns '8.8.8.8' "
}
elseif ( $dns -eq " usehostdns " ) {
2022-07-26 12:42:36 +03:00
$parameters + = " -dns 'hostDNS' "
2020-07-13 16:27:37 +03:00
}
2020-08-10 16:04:51 +03:00
if ( $ssl -eq " usessl " ) {
$parameters + = " -usessl "
}
elseif ( $ssl -eq " usessl2 " ) {
$parameters + = " -usessl -installCertificateOnHost "
}
2020-07-13 16:27:37 +03:00
if ( $isolation -ne " default " ) {
$parameters + = " -isolation ' $isolation ' "
}
if ( $memoryLimit ) {
$parameters + = " -memoryLimit $memoryLimit "
}
2020-08-24 20:30:52 +03:00
if ( $includeAL -eq " Y " ) {
if ( $exportAlSource -eq " Y " ) {
$parameters + = " -includeAL "
}
else {
$parameters + = " -includeAL -doNotExportObjectsToText "
}
}
2020-07-21 15:27:36 +03:00
if ( $includeCSIDE -eq " Y " ) {
2020-08-24 20:30:52 +03:00
if ( $exportCAlSource -eq " Y " ) {
$parameters + = " -includeCSIDE "
}
else {
$parameters + = " -includeCSIDE -doNotExportObjectsToText "
}
2020-07-21 15:27:36 +03:00
}
2020-09-03 17:46:51 +03:00
if ( $vsix -eq " Y " ) {
$parameters + = " -vsixFile (Get-LatestAlLanguageExtensionUrl) "
}
2020-07-13 16:27:37 +03:00
$script + = " New-BcContainer `` "
$script + = " -accept_eula `` "
$script + = " -containerName `$ containerName `` "
$parameters | ForEach-Object { $script + = " $_ `` " }
$script + = " -updateHosts "
if ( $createTestUsers -eq " Y " ) {
2020-07-15 12:22:08 +03:00
if ( $auth -eq " Windows " ) {
$script + = " Setup-BcContainerTestUsers -containerName `$ containerName -Password `$ credential.Password "
}
else {
$script + = " Setup-BcContainerTestUsers -containerName `$ containerName -Password `$ credential.Password -credential `$ credential "
}
2020-07-13 16:27:37 +03:00
}
$filename = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
_____ _____ _ _ _ _____ _ _
| __ \ / ____ | | | | | / ____ | ( _ ) | |
| | __ ) | ____ _____ _ __ ( ___ | | __ ___ | | | | ( ___ ___ _ __ _ _ __ | | _
| ___ / _ \ \ / \ / / _ \ '__\___ \| ' _ \ / _ \ | | \ ___ \ / __ | '__| | ' _ \ | __ |
| | | ( _ ) \ V V / __ / | ____ ) | | | | __ / | | ____ ) | ( __ | | | | | _ ) | | _
| _ | \ ___ / \ _ / \ _ / \ ___ | _ | | _____ / | _ | | _ | \ ___ | _ | _ | | _____ / \ ___ | _ | | _ | . __ / \ __ |
| |
| _ |
' @ `
-description " The below script will create a container with the requested settings: `n `n $( [ string ] :: Join ( " `n " , $script ) ) " `
-question " Enter filename to save and edit script (or blank to skip saving) " `
2020-07-13 16:27:37 +03:00
-default " blank "
if ( $filename -ne " blank " ) {
$filename = $filename . Trim ( '"' )
if ( $filename -notlike " *.ps1 " ) {
$filename + = " .ps1 "
}
if ( $filename . indexOf ( '\' ) -eq -1 ) {
$filename = Join-Path ( [ environment ] :: getfolderpath ( “ mydocuments ” ) ) $filename
}
$script | Out-File $filename
start -Verb Edit $filename
}
else {
$executeScript = Enter-Value `
-options @ ( " Y " , " N " ) `
-question " Execute Script " `
-doNotClearHost
if ( $executeScript -eq " Y " ) {
Invoke-Expression -Command ( [ string ] :: Join ( " `n " , $script ) )
}
2020-07-09 06:49:52 +03:00
}
2020-07-03 14:39:00 +03:00
}
2020-07-05 10:04:43 +03:00
else {
2020-07-21 15:27:36 +03:00
2020-07-13 16:27:37 +03:00
$emailforletsencrypt = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
__ ____ __ _____ _ _ __ _ _
/ \ \ \ / / \ / | / ____ | | | ( _ ) / _ ( _ ) | |
/ \ _____ _ _ __ ___ \ \ / / | \ / | | | ___ _ __ | | _ _ | | _ _ ___ __ _ | | _ ___
/ / \ \ | _ / | | | '__/ _ \ \ \/ / | |\/| | | | / _ \ ' __ | __ | | _ | | / __ / _ ` | __ / _ \
/ ____ \ / / | | _ | | | | __ / \ / | | | | | | ____ __ / | | | _ | | | | | ( __ ( _ | | | _ __ /
/ _ / \ _ \ ___ | \ __ , _ | _ | \ ___ | \ / | _ | | _ | \ _____ \ ___ | _ | \ __ | _ | _ | | _ | \ ___ \ __ , _ | \ __ \ ___ |
' @ `
2020-07-13 16:27:37 +03:00
-description " Your Azure VM can be secured by a Self-Signed Certificate, meaning that you need to install this certificate on any machine connecting to the VM. `n You can also select to use LetsEncrypt by specifying an email address of the person accepting subscriber agreement for LetsEncrypt (https://letsencrypt.org/repository/). `n `n Note: The LetsEncrypt certificate needs to be renewed after 90 days. " `
-question " Contact EMail for LetsEncrypt (blank to use Self Signed) " `
-default " blank "
$artifactUrl = [ Uri ] :: EscapeDataString ( " bcartifacts/ $type / $version / $country / $select " . ToLowerInvariant ( ) )
2020-07-05 10:04:43 +03:00
2020-07-13 16:27:37 +03:00
$url = " http://aka.ms/getbc?accepteula=Yes&artifacturl= $artifactUrl "
if ( $licenseFile ) {
$url + = " &licenseFileUri= $( [ Uri ] :: EscapeDataString ( $licenseFile ) ) "
}
2020-07-15 01:49:02 +03:00
if ( $testToolkit -ne " No " ) {
$url + = " &TestToolkit= $testToolkit "
}
2020-07-13 16:27:37 +03:00
if ( $assignPremiumPlan -eq " Y " ) {
$url + = " &AssignPremiumPlan=Yes "
}
if ( $createTestUsers -eq " Y " ) {
$url + = " &CreateTestUsers=Yes "
}
if ( $emailforletsencrypt -ne " blank " ) {
$url + = " &contactemailforletsencrypt= $( [ Uri ] :: EscapeDataString ( $emailforletsencrypt ) ) "
}
$launchUrl = Enter-Value `
2020-07-21 15:27:36 +03:00
-title @ '
__ ____ __ _ _ _____ _
/ \ \ \ / / \ / | | | | | __ \ | |
/ \ _____ _ _ __ ___ \ \ / / | \ / | | | | | | __ ) | |
/ / \ \ | _ / | | | ' __ / _ \ \ \ / / | | \ / | | | | | | _ / | |
/ ____ \ / / | | _ | | | | __ / \ / | | | | | | __ | | | \ \ | | ____
/ _ / \ _ \ ___ | \ __ , _ | _ | \ ___ | \ / | _ | | _ | \ ____ / | _ | \ _ \ ______ |
' @ `
-description " The URL below will launch the Azure Portal with an ARM template, which will create your VM: `n `n $url " `
2020-07-05 10:04:43 +03:00
-options @ ( " Y " , " N " ) `
2020-07-13 16:27:37 +03:00
-question " Launch Url "
2020-07-05 10:04:43 +03:00
2020-07-13 16:27:37 +03:00
if ( $launchUrl -eq " Y " ) {
Start-Process $Url
2020-07-05 10:04:43 +03:00
}
2020-07-03 14:39:00 +03:00
}
2020-07-03 09:42:26 +03:00
}
2020-07-03 14:39:00 +03:00
}
2020-07-13 16:27:37 +03:00
}