Meekers.Winget/Meekers.Winget.psm1
function Install-WingetLatest { <# .SYNOPSIS Download Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle and extract contents with 7zip cli to %ProgramData% .DESCRIPTION Downloads the latest version of WinGet and extracts it to %ProgramData% using 7zip cli. .EXAMPLE Install-WingetLatest #> $ProgressPreference = 'SilentlyContinue' $7zipFolder = "${env:WinDir}\Temp\7zip" try { Write-Host "`n ⬇️ Downloading WinGet... ⬇️ `n" -ForegroundColor Yellow # Create staging folder $StageFolder = New-Item -ItemType Directory -Path "${env:WinDir}\Temp\WinGet-Stage" -Force # Download Desktop App Installer msixbundle Invoke-WebRequest -UseBasicParsing -Uri "https://aka.ms/getwinget" -OutFile "${env:WinDir}\Temp\WinGet-Stage\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" } catch { Write-Host "`n❌Failed to download WinGet! ❌`n" -ForegroundColor Red Write-Host $_.Exception.Message return } try { Write-Host "`n ⬇️ Downloading 7zip CLI executable... ⬇️ `n" -ForegroundColor Yellow # Create temp 7zip CLI folder $TempZIp = New-Item -ItemType Directory -Path $7zipFolder -Force Invoke-WebRequest -UseBasicParsing -Uri https://www.7-zip.org/a/7zr.exe -OutFile "$7zipFolder\7zr.exe" Invoke-WebRequest -UseBasicParsing -Uri https://www.7-zip.org/a/7z2408-extra.7z -OutFile "$7zipFolder\7zr-extra.7z" Write-Host "`n 🔃 Extracting 7zip CLI executable to ${7zipFolder}...🔃 `n" -ForegroundColor Yellow $7zipexefile = & "$7zipFolder\7zr.exe" x "$7zipFolder\7zr-extra.7z" -o"$7zipFolder" -y } catch { Write-Host "`n ❌ Failed to download 7zip CLI executable! ❌ `n" -ForegroundColor Red Write-Host $_.Exception.Message return } try { # Create Folder for DesktopAppInstaller inside %ProgramData% $WingetDirLoc = New-Item -ItemType Directory -Path "${env:ProgramData}\Microsoft.DesktopAppInstaller" -Force Write-Host "`n 🔃 Extracting WinGet... 🔃 `n" -ForegroundColor Yellow $7zipmsix = & "$7zipFolder\7za.exe" x "${env:WinDir}\Temp\WinGet-Stage\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -o"${env:WinDir}\Temp\WinGet-Stage" -y $7zipAppmsix = & "$7zipFolder\7za.exe" x "${env:WinDir}\Temp\WinGet-Stage\AppInstaller_x64.msix" -o"${env:ProgramData}\Microsoft.DesktopAppInstaller" -y } catch { Write-Host "`n ❌ Failed to extract WinGet! ❌ `n" -ForegroundColor Red Write-Host $_.Exception.Message return } if (-Not (Test-Path "${env:ProgramData}\Microsoft.DesktopAppInstaller\WinGet.exe")) { Write-Host "`n ❌ Failed to extract WinGet! ❌ `n" -ForegroundColor Red exit 1 }elseif ((Test-Path "${env:ProgramData}\Microsoft.DesktopAppInstaller\WinGet.exe")) { Write-Host "`n ✅ WinGet successfully installed! ✅ `n" -ForegroundColor Green } $Script:WinGet = "${env:ProgramData}\Microsoft.DesktopAppInstaller\WinGet.exe" } |