Containers/Get-AppInfoFromContainer.ps1

<#
 .Synopsis
  Gets app info from the app file using the container existing
 .Description
  Gets the app info from an app file using the defined container
 .Parameter containerName
  container name to use to get the app info
 .Parameter appFile
  Filename to get app info from
 .Example
  $appInfo = Get-AppInfoFromContainer -containerName test appFile "C:\app.app"
#>

function Get-AppInfoFromContainer {
    Param (
        [Parameter(Mandatory = $true)]
        [string]$containerName,
        [Parameter(Mandatory = $true)]
        [string] $appFile
    )

    $containerAppFile = (Join-Path "C:\run\my\" (Split-Path $appFile -Leaf))
    Copy-FileToBcContainer -containerName $containerName -localPath $appFile -containerPath $containerAppFile | Out-Null

    Invoke-ScriptInBcContainer -containerName $containerName -scriptblock {
        $appinfo = Get-NAVAppInfo -Path $args[0]
        $dependencies = @()
        $appinfo.Dependencies | ForEach-Object {
            $dependencies = $dependencies + @{
                AppId = $_.AppId
                Name = $_.Name
                Publisher = $_.Publisher
                MinVersion = $_.MinVersion
                CompatibilityId = $_.CompatibilityId
                IsPropagated = $_.IsPropagated
                Version = $_.Version
            }
        }
        $app = @{
            Id = $appinfo.Id
            Name = $appinfo.Name
            Version = $appinfo.Version
            Publisher = $appinfo.Publisher
            ExtensionType = $appinfo.ExtensionType
            Scope = $appinfo.Scope
            Brief = $appinfo.Brief
            Description = $appinfo.Description
            CompatibilityId = $appinfo.CompatibilityId
            Dependencies = $dependencies
        }
        $app
    } -argumentList $containerAppFile
}