DimeScheduler.InstallBCExtension.ps1

<#PSScriptInfo
.VERSION 0.0.2.0
.GUID ddc4050c-9710-4183-b76d-1fd28c19d563
.AUTHOR Hendrik Bulens
.ICONURI https://cdn.dimescheduler.com/dime-scheduler/v2/shape.png
#>


<#
.SYNOPSIS
Deploys the Dime.Scheduler extension to the Business Central instance.
 
.DESCRIPTION
Deploys the Dime.Scheduler extension to the Business Central instance.
 
.PARAMETER serverInstance
The BC server instance
 
.PARAMETER version
The app version number to deploy
#>


param(   
    [Parameter(mandatory = $true, HelpMessage = "The server instance to deploy the extension to.")]
    [String]$serverInstance,

    [Parameter(mandatory = $true, HelpMessage = "The path to the .app file")]
    [String]$path,

    [Parameter(mandatory = $false, HelpMessage = "Optional switch to skip verification. Only use this for development and testing purposes.")]
    [switch]$skipVerification    
)

Write-Output ""
Write-Output ""
Write-Output "*"
Write-Output "**"
Write-Output "***"
Write-Output "****"
Write-Output "*****"
Write-Output "******"
Write-Output "*******"
Write-Output "********"
Write-Output "*********"
Write-Output "**********"
Write-Output "***********"
Write-Output "************"
Write-Output ""
Write-Output "_____ _ _____ _ _ _"
Write-Output "| __ \(_) / ____| | | | | | |"
Write-Output "| | | |_ _ __ ___ ___ | (___ ___| |__ ___ __| |_ _| | ___ _ __"
Write-Output "| | | | | '_ ` _ \ / _ \ \___ \ / __| '_ \ / _ \/ _` | | | | |/ _ \ '__|"
Write-Output "| |__| | | | | | | | __/_ ____) | (__| | | | __/ (_| | |_| | | __/ |"
Write-Output "|_____/|_|_| |_| |_|\___(_)_____/ \___|_| |_|\___|\__,_|\__,_|_|\___|_|"
Write-Output ""
Write-Output ""
Write-Output "Deploying the Dime.Scheduler extension to $serverInstance."
Write-Output ""
Write-Output "************"
Write-Output "***********"
Write-Output "**********"
Write-Output "*********"
Write-Output "********"
Write-Output "*******"
Write-Output "******"
Write-Output "*****"
Write-Output "****"
Write-Output "***"
Write-Output "**"
Write-Output "*"
Write-Output ""
Write-Output ""

function Green {
    process { Write-Host $_ -ForegroundColor Green }
}

function Orange {
    process { Write-Host $_ -ForegroundColor DarkYellow }
}

function Red {
    process { Write-Host $_ -ForegroundColor Red }
}

try {
    Write-Output "Step 1: Publish the app [PENDING]"  | Orange
    Publish-NAVApp -ServerInstance $serverInstance -Path $path -SkipVerification $skipVerification
    Write-Output "Step 1: Publish the app [COMPLETED]" | Green

    Write-Output "Step 2: Sync the app [PENDING]" | Orange
    Sync-NavApp -ServerInstance $serverInstance -Name "Dime.Scheduler"
    Write-Output "Step 2: Sync the app [COMPLETED]" | Green

    Write-Output "Step 3: Install the app [PENDING]" | Orange
    Install-NAVApp -ServerInstance $serverInstance -Name "Dime.Scheduler"
    Write-Output "Step 3: Install the app [COMPLETED]" | Green
}
catch {
    Write-Host "Couldn't install the extension for Dime.Scheduler in Business Central" | Red
    Write-Host $_
    return $_
}