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 } try { Find-PSResource -Name $Name -Repository $repoName -ErrorAction Stop | Add-Member -NotePropertyName Tenant -NotePropertyValue $feed.name -PassThru } catch { $msg = $_.Exception.Message if ($msg -match '\[Warning\].*CredentialProvider' -and $msg -notmatch '401|Unauthorized|forbidden') { # Credential provider emitted a deprecation warning (e.g. WIA obsolete) # but the query may have still succeeded. Retry with SilentlyContinue. Find-PSResource -Name $Name -Repository $repoName -ErrorAction SilentlyContinue | Add-Member -NotePropertyName Tenant -NotePropertyValue $feed.name -PassThru } elseif ($msg -match 'No match was found') { # Nothing matched — not an error, just no results. } else { Write-Warning "cciget: Find-PSResource failed against '$repoName': $msg" } } } } |