src/Install-CciModule.ps1

function Install-CciModule {
<#
.SYNOPSIS
    Install a CCI module from a tenant feed.
.PARAMETER Name
    Module name (required). Wildcards are not supported by Install-PSResource.
.PARAMETER Version
    Optional version constraint passed to Install-PSResource.
.PARAMETER Tenant
    Optional. Tenant feed to install from. If omitted, uses defaultFeed from
    Get-CciGetConfig.
.PARAMETER Scope
    CurrentUser (default) or AllUsers.
.EXAMPLE
    Install-CciModule Cci.Citrix
.EXAMPLE
    Install-CciModule Cci.Common -Tenant ccidev -Version 0.1.0
#>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory, Position = 0)]
        [string]$Name,
        [string]$Version,
        [string]$Tenant,
        [ValidateSet('CurrentUser','AllUsers')]
        [string]$Scope = 'CurrentUser',
        [switch]$Reinstall,
        [switch]$TrustRepository
    )

    if (-not $Tenant) { $Tenant = (Get-CciGetConfig).defaultFeed }
    $feed     = (_Resolve-CciGetFeed -Tenant $Tenant)[0]
    $repoName = _Get-CciGetRepositoryName -FeedName $feed.name

    if (-not (Get-PSResourceRepository -Name $repoName -ErrorAction SilentlyContinue)) {
        Connect-CciGet -Tenant $feed.name | Out-Null
    }

    $params = @{
        Name       = $Name
        Repository = $repoName
        Scope      = $Scope
    }
    if ($Version)         { $params.Version         = $Version }
    if ($Reinstall)       { $params.Reinstall       = $true }
    if ($TrustRepository) { $params.TrustRepository = $true }

    Install-PSResource @params
}