#
.SYNOPSIS
Install and configure Winget-AutoUpdate
.DESCRIPTION
This script will:
- Install Winget if not present
- Install Winget-AutoUpdate to get apps daily updated
- Install apps with Winget from a custom list file (apps.txt) or directly from popped up default list.
#>
<# APP INFO #>
# import Appx module if the powershell version is 7/core
if ( $psversionTable.PSEdition -eq "core" ) {
import-Module -name Appx -UseWIndowsPowershell -WarningAction:SilentlyContinue
}
$Script:WAUConfiguratorVersion = Get-Content "$PSScriptRoot\Winget-AutoUpdate\Version.txt"
<# FUNCTIONS #>
. "$PSScriptRoot\Winget-AutoUpdate\functions\Update-WinGet.ps1"
. "$PSScriptRoot\Winget-AutoUpdate\functions\Get-WingetCmd.ps1"
#Function to start or update popup
Function Start-PopUp ($Message) {
if (!$PopUpWindow) {
#Create window
$inputXML = @"
"@
[xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^ Removing admin rights for user context apps
}
## WAU PART ##
#Download and install Winget-AutoUpdate if box is checked
if ($InstallWAU) {
Start-PopUp "Installing WAU..."
#Set WAU subfolder
$WAUInstallFolder = "$PSScriptRoot\WAU"
#Configure parameters
$WAUParameters = "-Silent "
if ($WAUDoNotUpdate) {
$WAUParameters += "-DoNotUpdate "
}
if ($WAUDisableAU) {
$WAUParameters += "-DisableWAUAutoUpdate "
}
if ($WAUNotificationLevel) {
$WAUParameters += "-NotificationLevel $WAUNotificationLevel "
}
if ($WAUFreqUpd) {
$WAUParameters += "-UpdatesInterval $WAUFreqUpd "
}
if ($WAUAtUserLogon) {
$WAUParameters += "-UpdatesAtLogon "
}
if ($WAUonMetered) {
$WAUParameters += "-RunOnMetered "
}
if ($WAUUseWhiteList) {
$WAUParameters += "-UseWhiteList "
if ($WAUListPath) {
Copy-Item $WAUListPath -Destination "$WAUInstallFolder\included_apps.txt" -Force -ErrorAction SilentlyContinue
}
}
else {
if ($WAUListPath) {
Copy-Item $WAUListPath -Destination "$WAUInstallFolder\excluded_apps.txt" -Force -ErrorAction SilentlyContinue
}
}
if ($WAUDesktopShortcut) {
$WAUParameters += "-DesktopShortcut "
}
if ($WAUStartMenuShortcut) {
$WAUParameters += "-StartMenuShortcut "
}
if ($WAUInstallUserContext) {
$WAUParameters += "-InstallUserContext "
}
#Install Winget-Autoupdate
Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$WAUInstallFolder\Winget-AutoUpdate-Install.ps1 $WAUParameters`"" -Wait -Verb RunAs
}
## ADMIN PART ##
if ($CMTrace) {
Start-PopUp "Installing CMTrace..."
$CMToolkitLink = "https://github.com/Romanitho/Winget-Install-GUI/raw/main/Tools/cmtrace.exe"
$CMToolkitPath = "C:\Tools\CMTrace.exe"
Invoke-WebRequest $CMToolkitLink -OutFile (New-Item -Path $CMToolkitPath -Force)
Start-Sleep 1
}
if ($AdvancedRun) {
Start-PopUp "Installing AdvancedRun..."
$AdvancedRunLink = "https://www.nirsoft.net/utils/advancedrun-x64.zip"
$AdvancedRunPath = "C:\Tools\advancedrun-x64.zip"
Invoke-WebRequest $AdvancedRunLink -OutFile (New-Item -Path $AdvancedRunPath -Force)
Expand-Archive -Path $AdvancedRunPath -DestinationPath "C:\Tools\AdvancedRun" -Force
Start-Sleep 1
Remove-Item $AdvancedRunPath
}
if ($UninstallView) {
Start-PopUp "Installing UninstallView..."
$UninstallViewLink = "https://www.nirsoft.net/utils/uninstallview-x64.zip"
$UninstallViewPath = "C:\Tools\uninstallview-x64.zip"
Invoke-WebRequest $UninstallViewLink -OutFile (New-Item -Path $UninstallViewPath -Force)
Expand-Archive -Path $UninstallViewPath -DestinationPath "C:\Tools\UninstallView" -Force
Start-Sleep 1
Remove-Item $UninstallViewPath
}
#If Popup Form is showing, close
if ($PopUpWindow) {
#Installs finished
Start-PopUp "Done!"
Start-Sleep 1
#Close Popup
Close-PopUp
}
if ($CMTrace -or $AdvancedRun -or $UninstallView) {
Start-Process "C:\Tools"
}
}
function Start-Uninstallations ($AppToUninstall) {
#Download and run Winget-Install script if box is checked
if ($AppToUninstall) {
Start-PopUp "Uninstalling applications..."
#Run Winget-Install -Uninstall
$AppsToUninstall = "'$($AppToUninstall -join "','")'"
Start-Process "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -Command `"$PSScriptRoot\Winget-AutoUpdate\Winget-Install.ps1 -AppIDs $AppsToUninstall -Uninstall`"" -Wait -Verb RunAs
Close-PopUp
}
}
function Get-WAUInstallStatus {
$WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue
if ($WAUVersion -eq $WAUConfiguratorVersion) {
$WAULabelText = "WAU is currently installed (v$WAUVersion)."
$WAUStatus = "Green"
$WAUInstalled = $true
}
elseif ($WAUVersion) {
$WAULabelText = "WAU is currently installed (v$WAUVersion) but in another version!"
$WAUStatus = "Orange"
$WAUInstalled = $true
}
else {
$WAULabelText = "WAU is not installed."
$WAUStatus = "Red"
$WAUInstalled = $false
}
return $WAULabelText, $WAUStatus, $WAUInstalled
}
function Get-WAUConfiguratorLatestVersion {
### FORM CREATION ###
#Get latest stable info
$WAUConfiguratorURL = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
$WAUConfiguratorLatestVersion = (((Invoke-WebRequest $WAUConfiguratorURL -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")).Replace("-", ".")
if ([version]$WAUConfiguratorVersion -lt [version]$WAUConfiguratorLatestVersion) {
#Create window
$inputXML = @"
"@
[xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^
More info about WAU
"@
#Create window
[xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^
#Load assemblies
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName PresentationFramework
#Set some variables
$null = cmd /c ''
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$Script:ProgressPreference = "SilentlyContinue"
$Script:ErrorActionPreference = "SilentlyContinue"
$Script:AppToInstall = $null
$Script:InstallWAU = $null
$IconBase64 = [Convert]::FromBase64String("AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAMMOAADDDgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA39DIHd7Qx2Pdz8ec3c7FzNzOxezczcT/283E/9vNxOzbzcTQ3M7EoNzOxWDcz8QeAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA39LLNd7RyZne0Mjq39LK/+PY0f/p4Nv/7ebh/+/p5v/v6eb/7eXh/+je2f/i1s//3dDH/9zNxO7czsSd3M/GLwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4NLNEODTzIzf0sry4tbP/+3n4v/39fP//v39//////////////////////////////////38/P/39PL/7OTg/+HUzf/czcT03M7Gid3Pxw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODUzSrg08zM4dXN/+3m4v/7+fj/////////////////////////////////////////////////////////////////+/r5/+vk3//e0Mj/3M7FzNzPxi0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADh1s864dTN4eXb1f/38/H///////////////////////////////////////////////////////////////////////////////////////Xx7//i1s//3M7G4d7QyDoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA49bPLeLVzuHn3df/+vn4//////////////////////////////////////////////////////////////////////////////////////////////////r49//j2NH/3M/G4d3RxyoAAAAAAAAAAAAAAAAAAAAAAAAAAOLa0Q7i18/M5tzW//v5+P/////////////////////////////////+/Pr/9+ja/+/Uv//szLz/7My7/+/Sv//25tf//vv5//////////////////////////////////r49//j19D/3c/HzN/QyRAAAAAAAAAAAAAAAAAAAAAA49nSieTa0//39PL////////////////////////////+/fv/8Na+/+Ciav/XfwD/1HAA/9JoAP/RZgD/0mwA/9V5AP/dm2L/79S////9+/////////////////////7///////bz8P/f0sv/39HJjAAAAAAAAAAAAAAAAOPa0y/k2dH07+rm////////////////////////////+/Ts/+Sxhf/WeAD/1XUA/9uPPv/krnv/6cGk/+nBpP/jrXz/2ow9/9NuAP/TbwD/462E//ry6f//////9+ng/+Wzif/47OL//////+3m4f/e0Mjy3tLLNQAAAAAAAAAA5drTnejf2f/8+/v///////////////////////vz6v/ho2P/1ncA/9yQOf/u0Lb//Pbw///+/P/////////////+/P/79e7/7c61/9qLOv/SagD/3pth//348f/rzL3/zlMA/+vKuf//////+/n4/+LWz//f0sqZAAAAAOXc1B7l29Tu8evn/////////////////////////fv/5rWG/9d5AP/gnVT/+e3h////////////////////////////////////////////+Ozh/92WUf/SbAD/5bSQ/+rItf/QYQD/68q7////////////7ufj/9/Syurg08sd5tzWYOfd1//59/b///////////////////////HXv//ZgAD/3pU9//nt4f//////////////////////////////////////////////////////+Ozh/9qKOf/WfAD/3JNL/9JtAP/ry7z////////////49fP/4dXO/+HUzGPm3dag6uLd//79/f////////////////////7/6b2P/9l7AP/w07j/////////////////////////////////////////////////////////////////79K5/9V4AP/VewD/03EA/+vLvP////////////79/f/l29X/4NTMnOfd19Dv6OT////////////////////////////68Ob/89rD//779//////////////////////////////////////////////////57eP/68ar/+rFqf/ou5f/2IMa/9Z+AP/UcwD/68u7/////////////////+vj3//g1MzM6N7Y7PLt6////////////////////////////////////////////////////////////////////////////////////////////+m+lf/TaAD/1G8A/9RwAP/WdwD/1XYA/9NsAP/tzrz/////////////////7+nl/+HVzezo39n/9PDu////////////////////////////////////////////////////////////////////////////////////////////+e7k/+3Puv/tzrz/7c28/+3NvP/szbv/7s+8//vz6//////////////////y7On/4tXO/+ng2v/18e7//////////////////PXs//HVvf/v0rz/79K8/+/SvP/v0bz/79K6//rv5f////////////////////////////////////////////////////////////////////////////////////////////Lt6v/i18//6eHb7PPv7P/////////////////x1bz/3IgA/92MAP/diwD/24UA/9uCAP/ZewD/68OX////////////////////////////////////////////////////////////////////////////////////////////8Orn/+PX0Ozq4dzM8ezo//////////////////DTvP/ekAD/35YQ/+CYJP/sxJr/7syr/+7Mrf/57uP//////////////////////////////////////////////////vv3//LZw//67+b////////////////////////////t5uH/5NjS0Ovi3Zzu5+P//v7+////////////8dS8/9+SAP/glgD/35MA//LZvP/////////////////////////////////////////////////////////////////w07j/2HkA/+m8jv////7//////////////////v39/+ng2v/l2tOg7OTfY+zk4P/7+Pf////////////x1bz/35IA/+WqU//hmQb/46JA//rv4v//////////////////////////////////////////////////////+e7i/9+ZPv/agwD/8de////////////////////////59/X/5tzW/+Xb1WDs5OAd7OTf6vXw7v////////////HVvP/fjwD/8NO2/+zDlP/fkAD/5qxZ//rw4v////////////////////////////////////////////ru4v/ipFb/2oIA/+i3h////fv///////////////////////Hs6P/m3NXu5dzVHgAAAADs5eCZ7ufj//38+///////8dW6/96KAP/x1r7//fry/+eyaP/fkAD/5KRD//LXuP/89+/////9//////////////79//z38f/x1bj/4Zw9/9uFAP/kqmX/+/Tq///////////////////////8/Pv/6uHc/+bd150AAAAAAAAAAO3m4jXt5eHx9fHu///////68OT/7caQ//nu4f///////PXr/+vAif/glQD/35IA/+SlRv/qvYH/7sum/+7Lpv/pu4D/4qBE/92LAP/djAD/6bqI//z17P////////////////////////////Ls6f/n3df0593XLwAAAAAAAAAAAAAAAO3n44zu5+P/+vj3//////////////////////////////78//Tewv/os2n/4ZsA/9+RAP/ejAD/3YoA/96PAP/glwD/57Fu//PbwP///fz////////////////////////////49vT/6eDb/+nf2YkAAAAAAAAAAAAAAAAAAAAA7OnjEO7n48zw6uf//Pv7//////////////////////////////////78+f/57Nr/89zB//HVvP/x1bz/89zB//ns3P/+/fr//////////////////////////////////Pr5/+zl4P/p4NrM6ODYDgAAAAAAAAAAAAAAAAAAAAAAAAAA7+nlKe7n4+Dx6+j//Pv7//////////////////////////////////////////////////////////////////////////////////////////////////z7+v/u5+L/6eHb4evi2ywAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7+nlOu/o5OHx6+j/+vj3///////////////////////////////////////////////////////////////////////////////////////59/b/7ufi/+ri3eDr4906AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8OrmLO/p5czw6eb/9vLw//38/P/////////////////////////////////////////////////////////////////9/Pv/9PDt/+zl4P/r497M6+XeKQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8enpDvDq5onv6eX08ezo//by8P/7+vn//v7+//////////////////////////////////7+/v/7+fj/9fHv/+7o4//s5ODx7OTgjOvj3xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPHq5i/w6uWc7+nl7vDq5v/y7On/9PDt//bz8P/39PL/9/Ty//by8P/07+z/8Orn/+7n4//t5uHq7OXhmezl4TUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADw6+Ue8OrmYO/p5aDv6eXQ7+jl7O/o5P/u6OT/7ujk7O7n48zu5+Kc7efjY+zl5B0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/8AD//8AAP/8AAA/+AAAH/AAAA/gAAAHwAAAA8AAAAOAAAABgAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAGAAAABwAAAA8AAAAPgAAAH8AAAD/gAAB/8AAA//wAA///AA/8=")
Start-PopUp "Starting..."
#Check if WAUConfigurator is uptodate
Get-WAUConfiguratorLatestVersion
#Check if Winget is installed, and install if not
Update-WinGet
#Get WinGet cmd
$Script:Winget = Get-WingetCmd
#Run WAUConfigurator
Close-PopUp
Start-InstallGUI