AppHandling/Start-NavContainerAppDataUpgrade.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<#
 .Synopsis
  Upgrade App in NAV/BC Container
 .Description
  Creates a session to the container and runs the CmdLet Start-NAVAppDataUpgrade in the container
 .Parameter containerName
  Name of the container in which you want to upgrade the app (default navserver)
 .Parameter tenant
  Name of the tenant in which you want to upgrade the app (default default)
 .Parameter appName
  Name of app you want to upgrade in the container
 .Parameter appVersion
  Version of app you want to upgrade in the container
 .Example
  Start-NavContainerAppDataUpgrade -containerName test2 -appName myapp
#>

function  Start-NavContainerAppDataUpgrade {
    Param (
        [string] $containerName = "navserver",
        [string] $tenant = "default",
        [Parameter(Mandatory=$true)]
        [string] $appName,
        [Parameter(Mandatory=$false)]
        [string] $appVersion
    )

    Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param($appName, $appVersion, $tenant)
        Write-Host "Upgrading app $appName"
        $parameters = @{
            "ServerInstance" = $ServerInstance;
            "Name" = $appName;
            "Tenant" = $tenant
        }
        if ($appVersion)
        {
            $parameters += @{ "Version" = $appVersion }
        }
        Start-NAVAppDataUpgrade @parameters
    } -ArgumentList $appName, $appVersion, $tenant
    Write-Host -ForegroundColor Green "App successfully upgraded"
}
Set-Alias -Name Start-BCContainerAppDataUpgrade -Value Start-NavContainerAppDataUpgrade
Export-ModuleMember -Function Start-NavContainerAppDataUpgrade -Alias Start-BCContainerAppDataUpgrade