Module/BusinessCentral/Get-BCSAppsPerTenant.ps1

<#
.SYNOPSIS
 
.DESCRIPTION
 
.EXAMPLE
 
.NOTES
    Author: Mathias Stjernfelt
    Website: http://www.brightcom.se
#>

function Get-BCSAppsPerTenant {
    Param (
        [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)]
        [string]$serverInstance,
        [Parameter(ValueFromPipelineByPropertyName, Mandatory = $true)]
        [string]$tenant
    )
    begin {}

    process {
        Import-BCSDynamicsNavModules -ServerInstance $serverInstance

        $Hash = @();

        $AppInfos = Get-NAVAppInfo -ServerInstance $ServerInstance -Tenant $tenant -TenantSpecificProperties

        foreach ($AppInfo in $AppInfos) {
            $item = New-Object PSObject
            $item | Add-Member -type NoteProperty -Name 'AppId' -Value $AppInfo.AppId
            $item | Add-Member -type NoteProperty -Name 'Name' -Value $AppInfo.Name
            $item | Add-Member -type NoteProperty -Name 'Version' -Value $AppInfo.Version
            $item | Add-Member -type NoteProperty -Name 'ExtensionDataVersion' -Value $AppInfo.ExtensionDataVersion
            $item | Add-Member -type NoteProperty -Name 'Publisher' -Value $AppInfo.Publisher
            $item | Add-Member -type NoteProperty -Name 'Scope' -Value $AppInfo.Scope
            $item | Add-Member -type NoteProperty -Name 'IsInstalled' -Value $AppInfo.IsInstalled
            $item | Add-Member -type NoteProperty -Name 'IsPublished' -Value $AppInfo.IsPublished
            $item | Add-Member -type NoteProperty -Name 'SyncState' -Value $AppInfo.SyncState

            $Hash += $item
        }

        $Hash
    }
    end {
    }
}

Export-ModuleMember -Function Get-BCSAppsPerTenant