src/Install-CciPlatformModules.ps1

function Install-cciPlatformModules {
    [CmdletBinding()]
    param (
        $Name,
        $Scope = 'CurrentUser'
    )
    begin {
        Write-Verbose "Started running $($MyInvocation.MyCommand)"
    }
    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
        }
        $InstallModuleParams = @{
            "Scope" = $Scope
            "Repository" = $cciConnectionParams.cciPSRepository_Name
        }
        if ($Name) {
            $InstallModuleParams.Name = $Name
        }
        Install-Module @InstallModuleParams -Credential $AzDevOpsCred
    }
    end {
        Write-Verbose "Finished running $($MyInvocation.MyCommand)"
    }
}