Modules/businessdev.ALbuild.Feeds/Public/Find-BcPackage.ps1

function Find-BcPackage {
    <#
    .SYNOPSIS
        Finds the available versions of an AL app across feeds.
 
    .PARAMETER AppId
        The AL app id (GUID).
 
    .PARAMETER Name
        The app name (used for the package id scheme).
 
    .PARAMETER Publisher
        The app publisher (used for the package id scheme).
 
    .PARAMETER Feeds
        Feed providers. Defaults to the registered feeds (Get-BcFeed).
 
    .EXAMPLE
        Find-BcPackage -AppId '437dbf0e-84ff-417a-965d-ed2bb9650972' -Name 'Base Application' -Publisher 'Microsoft'
 
    .OUTPUTS
        PSCustomObject with Feed, PackageId, Version.
    #>

    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param(
        [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $AppId,
        [string] $Name,
        [string] $Publisher,
        [object[]] $Feeds
    )

    if (-not $Feeds -or $Feeds.Count -eq 0) { $Feeds = @(Get-BcFeed) }
    if (-not $Feeds -or $Feeds.Count -eq 0) { throw "No feeds available. Register one with Register-BcFeed or pass -Feeds." }

    foreach ($feed in $Feeds) {
        $packageId = $feed.MapPackageId($AppId, $Name, $Publisher)
        foreach ($version in $feed.GetVersions($packageId)) {
            [PSCustomObject]@{ Feed = $feed.Name; PackageId = $packageId; Version = $version }
        }
    }
}