Public/Install-Module.ps1

function Install-Module {
    <#
    .SYNOPSIS
        Warper to install a module on your VirtualEnv
    .PARAMETER Name
        Specifies an array of names of modules to install.
    .PARAMETER RequiredVersion
        Specifies the exact version number of the module to install.
    .PARAMETER Repository
        Specifies the friendly name of a repository that has been registered by running Register-PSRepository
    .PARAMETER Force
        Forces the command to run without asking for user confirmation.
    .PARAMETER Scope
        Specifies the installation scope of the module.
    .EXAMPLE
        Install-Module -Name Pester
        Install-Module -Name Pester -Force
        Install-Module -Name Pester -Scope CurrentUser
    .NOTES
        Version: 1.0.0
        Author: Thomas ILLIET
        Creation Date: 21/07/2018
    #>

    Param(
        [Parameter(Mandatory=$True)]
        [String[]]$Name,

        [Parameter(Mandatory=$False)]
        [Version]$RequiredVersion,

        [Parameter(Mandatory=$False)]
        [Version]$MinimumVersion,

        [Parameter(Mandatory=$False)]
        [Version]$MaximumVersion,

        [Parameter(Mandatory=$False)]
        [String]$Repository="PSGallery",

        [Parameter(Mandatory=$False)]
        [Switch]$Force,

        [Parameter(Mandatory=$False)]
        [ValidateSet('AllUsers','CurrentUser','VirtualEnv')]
        [String]$Scope="VirtualEnv"
    )

    # Get Dict of parameters
    $ModuleParams = Get-FunctionParameters

    foreach ($ModuleName in $Name) {
        Try {
            if($Scope -eq 'VirtualEnv') {
                if($VirtualenvFolder){
                    # Add Path to install module in Virtualenv Folder
                    $ModuleParams['Path'] = $VirtualenvFolder

                    # Remove Scope To avoid error on Save-Module
                    $ModuleParams.Remove("Scope")

                    # Save Module to Virtualenv
                    PowerShellGet\Save-Module @ModuleParams
                } else {
                    Write-Error "Virtualenv has not been Enabled, please run Enable-VirtualEnv !"
                }
            } else {
                PowerShellGet\Install-Module @ModuleParams
            }
        } Catch {
            Write-Error "Unable to install $ModuleName Module : $($_.Exception.Message)"
        }
    }
}