<# .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 = @"