Marli-Update.ps1

function Marli-Update{
    function New_Entry ([int]$xposi,[int]$yposi,[string]$Text,[System.ConsoleColor]$Color) {
      $position=$Host.ui.RawUI.CursorPosition
      $position.x = $xposi
      $position.y = $yposi
      $Host.ui.RawUI.CursorPosition = $position
      Write-Host $Text -ForegroundColor $Color
    }
    function UI-Preperation{
        param($Version)
        Clear-Host
        $ErrorActionPreference = "SilentlyContinue"
        $ProgressPreference = "SilentlyContinue"
        [console]::BufferWidth = [console]::WindowWidth
        [System.Console]::CursorVisible = $false
        $maxWS = $host.UI.RawUI.Get_MaxWindowSize()
        $ws = $host.ui.RawUI.WindowSize
        IF($maxws.width -ge 100)
        { $ws.width = 100 }
        ELSE { $ws.width = $maxws.width }
        IF($maxws.height -ge 20)
        { $ws.height = 20 }
        ELSE { $ws.height = $maxws.height }
        $host.ui.RawUI.Set_WindowSize($ws)

        Write-Host "Marlis Updater - Version $Version"
        Write-Host '---------------------------------'
        Write-Host ''
        Write-Host 'Preparation'
        Write-Host '[ ]--[ Check and Install Winget'
        Write-Host '[ ]--[ Check and Install Nuget'
        Write-Host '[ ]--[ Check and Install Module pswindowsupdate'
     }
    function Modules-Preperation{

        # Get WINGET module (and dependencies) ------------------------------------------------------
        New_Entry -xposi 1 -yposi 4 -Text '->' -Color Yellow
        Start-Process -FilePath PowerShell -ArgumentList { Invoke-WebRequest https://raw.githubusercontent.com/asheroto/winget-installer/master/winget-install.ps1 -UseBasicParsing | iex } -Wait -WindowStyle Hidden
        New_Entry -xposi 1 -yposi 4 -Text 'ok' -Color Green

        # Get Nuget module (and dependencies) ------------------------------------------------------
        New_Entry -xposi 1 -yposi 5 -Text '->' -Color Yellow
        $module = Import-PackageProvider -Name NuGet -ErrorAction Ignore
            if (-not $module) {       
             Install-PackageProvider -Name NuGet -Scope CurrentUser -Confirm:$false -Force | Out-Null
        }
        Import-PackageProvider  NuGet | Out-Null
        New_Entry -xposi 1 -yposi 5 -Text 'ok' -Color Green

        # Get pswindowsupdate module (and dependencies) --------------------------------------------
        New_Entry -xposi 1 -yposi 6 -Text '->' -Color Yellow
        $module = Import-Module pswindowsupdate -PassThru -ErrorAction Ignore
        if (-not $module) {
            Install-Module pswindowsupdate -Confirm:$false -Force | Out-Null
        }
        Import-Module pswindowsupdate -Scope Global | Out-Null
        New_Entry -xposi 1 -yposi 6 -Text 'ok' -Color Green
    }
    function UI-Menu{
        param($Version)

        Clear-Host
        Write-Host "Marlis Updater - Version $Version"
        Write-Host '---------------------------------'
        Write-Host ''
        Write-Host '[' -NoNewline
        Write-Host '1' -NoNewline -ForegroundColor Green
        Write-Host ']----[ ' -NoNewline
        Write-Host 'Update my Software' -ForegroundColor Yellow
        Write-Host '[' -NoNewline
        Write-Host '2' -NoNewline -ForegroundColor Green
        Write-Host ']----[ ' -NoNewline
        Write-Host 'Update my Windows' -ForegroundColor Yellow
        Write-Host ''
    }
    #>-----------------------------------------------------------------------------

    $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
    $testadmin = $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
    if ($testadmin -eq $false) {
       Write-Host 'This command need adminstrator rights.' -ForegroundColor Red
       break
    }

    $Version = '1.0.7'
    UI-Preperation -Version $Version  
    Modules-Preperation
    UI-Menu -Version $Version  
    $Selectvalue = Read-Host -Prompt 'Select and Enter'

    If ($Selectvalue -eq 1){
        Write-Host 'Checking Updates...' -ForegroundColor Yellow
        winget upgrade --all
        Write-Host 'done' -ForegroundColor Green
    }
    elseif ($Selectvalue -eq 2){
        Write-Host 'Checking Updates...' -ForegroundColor Yellow
        Get-WindowsUpdate -AcceptAll -Install
        Write-Host 'done' -ForegroundColor Green
    }    
}