InstallLogetoModule.ps1

Function Write-LogetoProgress([String] $text, [String] $code)
{
    if (Get-Command -CommandType Function -Name "Write-InstallerProgress" -ErrorAction SilentlyContinue)
    {
       Write-InstallerProgress $text $code
    } 
    else
    {
       Write-Host $text
    }
}

Function Write-LogetoDebug([String] $text)
{
    if (Get-Command -CommandType Function -Name "Write-InstallerDebug" -ErrorAction SilentlyContinue)
    {
       Write-InstallerDebug $text
    } 
    else
    {
        Write-Host $text
    }
}


Function InstallLogetoModule()
{
    try
    {
        if (!(Get-PSRepository -Name "PSGallery"))
        {
            Write-LogetoDebug "PSGallery is being registered."
            Register-PSRepository -Default
        }

        Write-LogetoDebug "Getting NuGet package provider."
        if (!(Find-PackageProvider -Name "NuGet" -ForceBootstrap -Force))
        {
            Get-PackageProvider -Name "NuGet" -ForceBootstrap -Force
        }

        if (Get-Module -ListAvailable -Name Logeto) 
        {
            Write-LogetoDebug "Updating Logeto Powershell Module."
            $local = Get-Module -ListAvailable -Name "Logeto"
            $online = Find-Module -Name "Logeto"
            if ($online.version -gt $local.version)
            {
                   Update-Module -Name "Logeto" -Force
            }
        } 
        else 
        {
            Write-LogetoDebug "Installing Logeto Powershell Module."
            Install-Module -Name "Logeto" -Scope CurrentUser -Force
        }
    }
    catch
    {
        Write-LogetoDebug "Logeto Powershell module could not been installed/updated ($_)"
    }
}

Write-LogetoProgress "Installing Logeto module" "ScriptImportLogetoModule"
InstallLogetoModule;