Containers/Install-AppIntoContainer.ps1
function Install-AppIntoContainer { Param( [Parameter(Mandatory=$true)] [string]$ComputerName, [Parameter(Mandatory=$true)] [string]$AppPath ) $Session = New-DockerPortalSession $ComputerName $FileName = 'C:\run\my\{0}' -f (Split-Path $AppPath -Leaf) Copy-Item -Path $AppPath -ToSession $Session -Destination $FileName Invoke-Command -Session $Session -ScriptBlock { Import-Module 'C:\Program Files\Microsoft Dynamics NAV\*\Service\Microsoft.Dynamics.Nav.Apps.Management.psd1' $AppName = (Get-NavAppInfo -Path $using:FileName).Name Write-Host ("Installing $AppName into {0}" -f (hostname)) -ForegroundColor Green $AppExists = (Get-NavAppInfo NAV -Name $AppName -Tenant default -TenantSpecificProperties:$false) -ne $null if ($AppExists) { Uninstall-NavApp NAV -Name $AppName Unpublish-NavApp NAV -Name $AppName Publish-NavApp NAV -Path $using:FileName -SkipVerification Sync-NavApp NAV -Name $AppName Start-NavAppDataUpgrade NAV -Name $AppName } else { Publish-NavApp NAV -Path $using:FileName -SkipVerification Sync-NAVApp NAV -Name $AppName Install-NavApp NAV -Name $AppName } } } Export-ModuleMember -Function Install-AppIntoContainer |