Private/Scriptblocks.ps1

$installD365Module = {
    try {
        Stop-Transcript | out-null
    }
    catch {
        $error.clear()   
    }
    New-Item -ItemType Directory -Force -Path C:\Install\Log -ErrorAction SilentlyContinue | Out-Null
    Start-Transcript -Path "C:\Install\Log\InstallD365Module.$(get-date -format yyyyMMddhhmmss).log"
    if (Get-Module -Name SetupD365Environment -ListAvailable) {
        Update-Module -Name SetupD365Environment -Force
    }
    else {
        Install-Module -Name SetupD365Environment -Force
    }
    Stop-Transcript
}

$initializeVm = {
    Param(
        [parameter(Mandatory = $true)][String]$test
    )
    $ErrorActionPreference = "SilentlyContinue"
    try {
        Stop-Transcript | out-null
    }
    catch {
        $error.clear()
    }
    New-Item -ItemType Directory -Force -Path C:\Install\Log -ErrorAction SilentlyContinue | Out-Null
    Start-Transcript -Path "C:\Install\Log\InitVM.$(get-date -format yyyyMMddhhmmss).log"
    if (-not([string]::IsNullOrEmpty($test))) {
        Write-Host "Variable enthaelt: $test"
    }
    Import-Module -Name SetupD365Environment
    Initialize-CustomAzVm
    Stop-Transcript
}

$downloadBCDVD = {
    Param(
        [Parameter(Mandatory = $false, Position = 3)]
        [string]
        $Version,
        [Parameter(Mandatory = $false, Position = 4)]
        [string]
        $CumulativeUpdate,
        [Parameter(Mandatory = $false, Position = 5)]
        [string]
        $Language
    )
    Write-Host "Version: $Version CU: $CumulativeUpdate Lang: $Language..."
    Receive-BusinessCentralDVD -Version $Version -CumulativeUpdate $CumulativeUpdate -Language $Language
}