src/Find-CciModule.ps1

function Find-CciModule {
<#
.SYNOPSIS
    Search registered CCI feeds for modules.
.PARAMETER Name
    Module name or wildcard. Defaults to '*'.
.PARAMETER Tenant
    Optional. Restrict search to a single tenant feed.
.EXAMPLE
    Find-CciModule Cci.Citrix
.EXAMPLE
    Find-CciModule -Tenant ccidev *
#>

    [CmdletBinding()]
    param(
        [Parameter(Position = 0)]
        [string]$Name = '*',
        [string]$Tenant
    )

    $feeds = _Resolve-CciGetFeed -Tenant $Tenant
    foreach ($feed in $feeds) {
        $repoName = _Get-CciGetRepositoryName -FeedName $feed.name
        if (-not (Get-PSResourceRepository -Name $repoName -ErrorAction SilentlyContinue)) {
            Write-Warning "cciget: feed '$($feed.name)' not registered. Run Connect-CciGet to set up feeds."
            continue
        }
        $findErrors = $null
        $results = Find-PSResource -Name $Name -Repository $repoName -ErrorAction SilentlyContinue -ErrorVariable findErrors
        if ($results) {
            $results | Add-Member -NotePropertyName Tenant -NotePropertyValue $feed.name -PassThru
        } elseif ($findErrors) {
            # Check if errors are real failures or just credential provider warnings.
            $realErrors = @($findErrors | Where-Object {
                $_.Exception.Message -notmatch '\[Warning\].*CredentialProvider' -and
                $_.Exception.Message -notmatch 'No match was found'
            })
            if ($realErrors.Count -gt 0) {
                Write-Warning "cciget: Find-PSResource failed against '$repoName': $($realErrors[0].Exception.Message)"
            }
        }
    }
}