src/Find-cciModule.ps1

function Find-cciModule {
    [CmdletBinding()]
    param (
        $Name
    )
    begin {
        Write-Verbose "Started running $($MyInvocation.MyCommand)"
        $cciConnectionParams = Get-cciConnectionParams
    }
    process {
        if ($null -eq (Get-PSRepository -Name $cciConnectionParams.cciPSRepository_Name -ErrorAction SilentlyContinue)) {
            $RegisterPSRepositoryParams = @{
                "Name" = $cciConnectionParams.PSRepository_Name
                "SourceLocation" = $cciConnectionParams.PSRepository_SourceLocation
                "PackageManagementProvider" = $cciConnectionParams.PSRepository_PackageManagementProvider
                "InstallationPolicy" = $cciConnectionParams.PSRepository_InstallationPolicy
            }
            Register-PSRepository @RegisterPSRepositoryParams
        }
        if ($null -eq $script:AzDevOpsCred) {
            $GetCciAzDevOpsCredentialParams = @{
                "KeyvaultName" = $cciConnectionParams.azKeyVaultSecret_VaultName
                "SecretName" = $cciConnectionParams.azKeyVaultSecret_Name
                "Patusername" = $cciConnectionParams.cciAzDevOpsCredential_patusername
            }
            $AzDevOpsCred = Get-cciAzDevOpsCredential @GetCciAzDevOpsCredentialParams
        }
        $FindModuleParams = @{
            "Repository" = $cciConnectionParams.cciPSRepository_Name
        }
        if ($Name) {
            $FindModuleParams.Name = $Name
        }
        Find-Module @FindModuleParams -Credential $AzDevOpsCred
    }
    end {
        Write-Verbose "Finished running $($MyInvocation.MyCommand)"
    }
}