DimeScheduler.InstallBCExtension.ps1
<#PSScriptInfo
.VERSION 0.0.3.0 .GUID ddc4050c-9710-4183-b76d-1fd28c19d563 .AUTHOR Hendrik Bulens .COMPANYNAME Dime Software .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. You can use either the -version parameter to download the latest available extension, or you can specify your own .app file through the -path argument. .PARAMETER serverInstance Required. The BC server instance. .PARAMETER version Optional. The supported BC wave that is being targeted: 13,14,15,16,17,18,19,20,21,22,23,24 .PARAMETER path Optional. Use this parameter to deploy your own .app file. .PARAMETER skipVerification Optional. Switch to skip verification: Only use this for development and testing purposes! #> param( [Parameter(mandatory = $true, HelpMessage = "Required. The BC server instance.")] [String]$serverInstance, [Parameter(mandatory = $false, HelpMessage = "Optional. The supported BC wave that is being targeted: 13,14,15,16,17,18,19,20,21,22,23,24")] [ValidateSet(13,14,15,16,17,18,19,20,21,22,23,24)] [int]$version, [Parameter(mandatory = $false, HelpMessage = "Optional. Use this parameter to deploy your own .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 } } function Check-Command($cmdname) { return [bool](Get-Command -Name $cmdname -ErrorAction SilentlyContinue) } try { if ((Check-Command -cmdname 'Publish-NAVApp') -eq $false) { Write-Output "This script must be run in a Business Central Administration Shell." | Red return; } if(!$path -and $version -eq $null){ Write-Output "Either of the -version or -path parameters is required." | Red return; } if(!$path) { Write-Output "Download the app [PENDING]" | Orange $fileName = 'Dime.Scheduler.app' $appUrl = "https://storage.dimescheduler.com/bcextensions/${version}/${fileName}" Invoke-WebRequest $appUrl -OutFile $fileName $path = Join-Path $PSScriptRoot $fileName Write-Output "Download the app [COMPLETED]" | Green } Write-Output "Publish the app [PENDING]" | Orange Publish-NAVApp -ServerInstance $serverInstance -Path $path -SkipVerification $skipVerification Write-Output "Publish the app [COMPLETED]" | Green Write-Output "Sync the app [PENDING]" | Orange Sync-NavApp -ServerInstance $serverInstance -Name "Dime.Scheduler" Write-Output "Sync the app [COMPLETED]" | Green Write-Output "Install the app [PENDING]" | Orange Install-NAVApp -ServerInstance $serverInstance -Name "Dime.Scheduler" Write-Output "Install the app [COMPLETED]" | Green Write-Output "The extension for Dime.Scheduler has been installed and will be available shortly!" | Green } catch { Write-Output "Couldn't install the extension for Dime.Scheduler in Business Central." | Red Write-Output $_ | Red return $_ } |