Modules/businessdev.ALbuild.Apps/Public/Uninstall-BcContainerApp.ps1
|
function Uninstall-BcContainerApp { <# .SYNOPSIS Uninstalls an AL app in a Business Central container. .PARAMETER Name Container name. .PARAMETER AppName The app name. .PARAMETER AppVersion Optional app version. .PARAMETER ServerInstance BC server instance. Default 'BC'. .PARAMETER Tenant Tenant. Default 'default'. .PARAMETER DockerExecutable The Docker executable to use (default 'docker'). #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [Alias('ContainerName')] [string] $Name, [Parameter(Mandatory)] [string] $AppName, [string] $AppVersion, [string] $ServerInstance = 'BC', [string] $Tenant = 'default', [switch] $Force, [string] $DockerExecutable = 'docker' ) if (-not $PSCmdlet.ShouldProcess($Name, "Uninstall $AppName")) { return } $output = Invoke-BcContainerCommand -ContainerName $Name -DockerExecutable $DockerExecutable -Variables @{ ServerInstance = $ServerInstance; AppName = $AppName; AppVersion = $AppVersion; Tenant = $Tenant; Force = [bool]$Force } -ScriptBlock { $params = @{ ServerInstance = $ServerInstance; Name = $AppName; Tenant = $Tenant; ErrorAction = 'Stop' } if ($AppVersion) { $params['Version'] = $AppVersion } if ($Force) { $params['Force'] = $true } # drop app data so an installed app can be removed for a clean redeploy Uninstall-NAVApp @params Write-Output "Uninstalled $AppName" } Write-ALbuildLog -Level Success ($output.Trim()) } |