functions/Install-RequiredModule.ps1

<#
    .SYNOPSIS
 
    Imports/Installs a module required to run this module/function
 
    .DESCRIPTION
 
    Attempts to load a local module first - if the module isn't available it will attempt to download/install from PSGallery.
 
    .PARAMETER ModuleName
 
    Name of the module to install
 
    .PARAMETER Scope
 
    Scope used to install the module - default is CurrentUser
 
    .EXAMPLE
 
    Install-RequiredModule -ModuleName dbatools
#>

function Install-RequiredModule{
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true)]
        [ValidateNotNullorEmpty()]
        [string] $ModuleName,
        [string] $Scope = "CurrentUser",
        [version] $RequiredVersion
    )

    Write-DosTelemetry -Message "Install-RequiredModule start"
    # Adding PSModule path becuse in some cases the path to user directory was not in the module system path
    $currentUserPSModulePath = "$home\Documents\WindowsPowerShell\Modules"
    $replaceCurrentUserModulePath = Add-ToPSModulePath -Path $currentUserPSModulePath

    #First scenario - required version of the module is already loaded
    $importedModule = Get-ModuleWorkAround -Name $ModuleName

    if($null -ne $importedModule){
        Write-DosMessage -Level "Information" -Message "Module '$ModuleName' already imported."
        
        if ($RequiredVersion) {
            Write-DosMessage -Level "Verbose" -Message "Checking if imported module '$ModuleName' matches required version '$RequiredVersion'."
            if ((Compare-ModuleVersion -ModuleToCompare $importedModule -RequiredVersion $RequiredVersion)) {
                Write-DosMessage -Level "Information" -Message "Confirming '$ModuleName' with version '$RequiredVersion' is loaded into session."
                
                if ($importedModule.Count -gt 1) {
                    Write-DosMessage -Level "Information" -Message "Multiple '$ModuleName' modules loaded in session. This should never happen?"
                    Remove-Module -Name $ModuleName
                    Import-Module -Name $ModuleName -RequiredVersion $RequiredVersion
                    Write-DosMessage -Level "Information" -Message "Successfully imported '$ModuleName' with version '$RequiredVersion' into session."
                    Write-DosTelemetry -Message "Multiple modules found in session. Removed all and successfully imported '$ModuleName' with version '$RequiredVersion' into session."
                }
                else {
                    Write-DosMessage -Level "Information" -Message "Using '$ModuleName' that is currently loaded in the session."
                    Write-DosTelemetry -Message "Using '$ModuleName' that is currently loaded in the session."
                }

                # Removing user path from ps module to cover cases in it is not included in system path
                if ($replaceCurrentUserModulePath) {
                    Remove-FromPSModulePath -Path $currentUserPSModulePath
                }
                return
            }
            else {
                Write-DosMessage -Level "Information" -Message "Removing '$ModuleName' that does not match required version '$RequiredVersion'."
                
                Remove-Module -Name $ModuleName
            }
        }
        else {
            # Removing user path from ps module to cover cases in it is not included in system path
            if ($replaceCurrentUserModulePath) {
                Remove-FromPSModulePath -Path $currentUserPSModulePath
            }
            return
        }
    }

    Write-DosMessage -Level "Information" -Message "Did not find module '$ModuleName' loaded in session."
    
    # Second scenario is required version of the module is installed on the system
    Write-DosMessage -Level "Information" -Message "Checking if module '$ModuleName' is already installed."
    $installedModule = Get-ModuleWorkAround -Name $ModuleName -ListAvailable
        
    if($null -ne $installedModule){
        Write-DosMessage -Level "Information" -Message "Module '$ModuleName' already installed."
        if ($RequiredVersion) {
            Write-DosMessage -Level "Verbose" -Message "Checking if installed module '$ModuleName' matches required version '$RequiredVersion'."
            if ((Compare-ModuleVersion -ModuleToCompare $installedModule -RequiredVersion $RequiredVersion)) {
                Write-DosMessage -Level "Information" -Message "Importing '$ModuleName' with version '$RequiredVersion'."
                Import-Module $ModuleName -RequiredVersion $RequiredVersion
                Write-DosTelemetry -Message "'$ModuleName' found on the system and successfully imported with version '$RequiredVersion'"

                if ($replaceCurrentUserModulePath) {
                    Remove-FromPSModulePath -Path $currentUserPSModulePath
                }
                return
            }                        
        }
        else {
            Write-DosMessage -Level "Information" -Message "Module '$ModuleName' is installed on system, attempting to import."
            Import-Module $ModuleName
            Write-DosTelemetry -Message "'$ModuleName' found on the system and successfully imported with version"

            if ($replaceCurrentUserModulePath) {
                Remove-FromPSModulePath -Path $currentUserPSModulePath
            }
            return
        }
    }

    Write-DosMessage -Level "Information" -Message "Did not find module '$ModuleName' installed on system."
    #Third scenario is module is installed from PSGallery
    $psVersion = Get-PSVersion

    if ($psVersion.PSVersion.Major -ge 5) {
        Write-DosMessage -Level "Information" -Message "Attempting to fetch '$ModuleName'."

        $desiredRepo = "PSGallery"
        $isTrusted = Get-RepositoryTrust -RepositoryName $desiredRepo

        if (!($isTrusted)) {
            Write-DosMessage -Level "Information" -Message "'$desiredRepo' is not trusted. Toggling trust to download '$ModuleName'"
            Set-RepositoryTrust -RepositoryName $desiredRepo -Trust
        }

        #Error check here - also assume that PowerShellGet is loaded/available.
        try {
            if ($RequiredVersion) {
                Write-DosMessage -Level "Information" -Message "Module '$ModuleName' version '$RequiredVersion' being downloaded from PSGallery."
                Install-Module $ModuleName -RequiredVersion $RequiredVersion -Scope $scope
                Write-DosMessage -Level "Information" -Message "Successfully downloaded module '$ModuleName' with version '$RequiredVersion' from PSGallery."
                Import-Module $ModuleName -RequiredVersion $RequiredVersion
                Write-DosMessage -Level "Information" -Message "Successfully imported module '$ModuleName' with version '$RequiredVersion' from PSGallery."
                Write-DosTelemetry -Message "Successfully imported module '$ModuleName' with version '$RequiredVersion' from PSGallery."
            }
            else {
                Write-DosMessage -Level "Information" -Message "Module '$ModuleName' being downloaded from PSGallery."
                Install-Module $ModuleName -Scope $scope
                Write-DosMessage -Level "Information" -Message "Successfully downloaded module '$ModuleName' from PSGallery."
                Import-Module $ModuleName
                Write-DosMessage -Level "Information" -Message "Successfully imported module '$ModuleName' from PSGallery."
                Write-DosTelemetry -Message "Successfully imported module '$ModuleName' from PSGallery."
            }
        }
        catch {
            Write-DosMessage -Level "Error" -Message "Error installing or importing '$ModuleName'. Exception: $($_.Exception)"
            if (!($isTrusted)) {
                Write-DosMessage -Level "Information" -Message "Returning '$desiredRepo' to an untrusted state."
                Set-RepositoryTrust -RepositoryName $desiredRepo
            }
        }

        if (!($isTrusted)) {
            Write-DosMessage -Level "Information" -Message "Returning '$desiredRepo' to an untrusted state."
            Set-RepositoryTrust -RepositoryName $desiredRepo
        }
    }
    else {
        Write-DosMessage -Level "Fatal" -Message "Unable to install required module: '$ModuleName'. Insufficient PowerShell Version: $psVersion, PowerShell Version 5.0 or greater is required to download from PSGallery"
    }

    if ($replaceCurrentUserModulePath) {
        Remove-FromPSModulePath -Path $currentUserPSModulePath
    }

    Write-DosTelemetry -Message "Install-RequiredModule completed - successfully"
}

#Work around for pester issue: https://github.com/pester/Pester/issues/1007
function Get-ModuleWorkAround{
    param(
        [string] $Name,
        [switch] $ListAvailable
    )


    if($ListAvailable.IsPresent){
        return Get-Module -Name $Name -ListAvailable
    }
    else {
        return Get-Module -Name $Name
    }
}

function Get-RepositoryTrust {
    param (
        [string] $RepositoryName
    )

    $repo = Get-PSRepository -Name $RepositoryName
    return $repo.Trusted
}

function Set-RepositoryTrust {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Justification="WhatIf support not implemented.")]
    param (
        [string] $RepositoryName,
        [switch] $Trust
    )

    if ($Trust.IsPresent) {
        Set-PSRepository -Name $RepositoryName -InstallationPolicy Trusted
    }
    else {
        Set-PSRepository -Name $RepositoryName -InstallationPolicy Untrusted
    }
}

function Add-ToPSModulePath {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true)]
        [string] $Path
    )

    if (!($env:PSModulePath.split(";") -contains $Path)){
        Write-DosMessage -Level "Information" -Message "Adding '$Path' to PSModulePath"
        $current = $env:PSModulePath
        [Environment]::SetEnvironmentVariable("PSModulePath",$current + ";" + $Path, "Machine")
        $env:PSModulePath = [System.Environment]::GetEnvironmentVariable("PSModulePath","Machine")
        return $true
    }else{
        Write-DosMessage -Level "Information" -Message "'$Path' is already present in PSModulePath"
        return $false
    }
}

function Remove-FromPSModulePath{
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Justification="WhatIf support not implemented.")]
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true)]
        [string] $Path
    )
    if ($env:PSModulePath.split(";") -contains $Path){
        $newValue = (($env:PSModulePath).Split(";") | Where-Object { $_ -ne $Path }) -join ";"
        [Environment]::SetEnvironmentVariable("PSModulePath", $newValue, "Machine")
        $env:PSModulePath = [System.Environment]::GetEnvironmentVariable("PSModulePath","Machine")
        Write-DosMessage -Level "Information" -Message "$Path removed from PSModulePath." 
    }else{
        Write-DosMessage -Level "Information" -Message "$Path is not present in $env:PSModulePath"
    }
}

function Compare-ModuleVersion {
    [CmdletBinding()]
    param(
        [object] $ModuleToCompare,
        [version] $RequiredVersion
    )

    $isMatch = $false

    foreach($module in $ModuleToCompare) {
        if ($module.Version.CompareTo($RequiredVersion) -eq 0) {
            Write-DosMessage -Level "Information" -Message "Found Module '$ModuleName' that meets the version requirements."
            $isMatch = $true
            break;
        }
    }

    if (!$isMatch) {
        Write-DosMessage -Level "Information" -Message "No module with version '$RequiredVersion' was found for module '$ModuleName'."
        
    }

    return $isMatch
}
# SIG # Begin signature block
# MIIcRgYJKoZIhvcNAQcCoIIcNzCCHDMCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBXZworQkNjoFTX
# 9Td6jMGvZ9mm2nd7r7qwQElMBhV6KKCCCqAwggUwMIIEGKADAgECAhAECRgbX9W7
# ZnVTQ7VvlVAIMA0GCSqGSIb3DQEBCwUAMGUxCzAJBgNVBAYTAlVTMRUwEwYDVQQK
# EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xJDAiBgNV
# BAMTG0RpZ2lDZXJ0IEFzc3VyZWQgSUQgUm9vdCBDQTAeFw0xMzEwMjIxMjAwMDBa
# Fw0yODEwMjIxMjAwMDBaMHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2Vy
# dCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNVBAMTKERpZ2lD
# ZXJ0IFNIQTIgQXNzdXJlZCBJRCBDb2RlIFN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