An advanced PowerShell script to automate application updates via winget.
![image](https://private-user-images.githubusercontent.com/76112223/411629943-5863fdf3-6cd8-47d8-b346-4a574fc45c61.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5NzE2MTQsIm5iZiI6MTczOTk3MTMxNCwicGF0aCI6Ii83NjExMjIyMy80MTE2Mjk5NDMtNTg2M2ZkZjMtNmNkOC00N2Q4LWIzNDYtNGE1NzRmYzQ1YzYxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE5VDEzMjE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk0N2MwNGIwZWY0ZTA4OTY5YWIzMGQ4OGU2ZGMyZjhhY2Y2Mjk1MDdkODBlMjE4M2FkODY1ZmU5NjdkMDgxMDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.h-_LPbs_iVz2QPztgiHDYO5zy2h0lGIHMshFIHlP-Kw)
Winget-Update is a PowerShell script designed to simplify and automate the process of updating applications via the Windows Package Manager (winget). It offers increased flexibility and advanced features for users and system administrators.
- Automatic application updates via winget
- Multiple update modes (normal, silent, forced, etc.)
- Temporary or persistent application exclusion
- Support for custom parameters for winget
- User-friendly command-line interface
- Windows 10 (version 1809 or later) or Windows 11
- PowerShell 5.1 or later
- Windows Package Manager (winget)
-
Ensure winget is installed on your system.
- To check, open PowerShell and type
winget --version
- If winget is not recognised, install it from the Microsoft Store
- To check, open PowerShell and type
-
Obtain the
winget-update.ps1
script:Option A: Clone the Git repository (recommended)
- Open PowerShell
- Navigate to the folder where you want to clone the repository
- Run the command:
git clone https://github.com/sterbweise/winget-update.git
Option B: Download the script directly
- Visit https://github.com/sterbweise/winget-update
- Click on the
winget-update.ps1
file - Click on the "Raw" button
- Right-click and select "Save as..."
- Choose the save location and click "Save"
-
Add the folder containing the script to your PATH environment variable:
- Open PowerShell as administrator
- Run the following command, replacing
C:\Path\To\The\Folder
with the actual path to the folder containing the script:[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Path\To\The\Folder", "Machine")
- Close and reopen PowerShell for the changes to take effect
-
Create a PowerShell alias for the script:
- Open your PowerShell profile by typing
notepad $PROFILE
in PowerShell - If the file doesn't exist, create it
- Add the following line to the file:
Set-Alias -Name winget-update -Value winget-update.ps1
- Save and close the file
- Reload your PowerShell profile by typing
. $PROFILE
- Open your PowerShell profile by typing
You can now run winget-update
from any location in PowerShell.
Open PowerShell and navigate to the directory containing the script. Run it with the desired parameters: powershell .\winget-update.ps1 [options]
-ExcludeApps
or-e
: Specifies applications to exclude from the current update.-Mode
or-m
: Sets the update mode.-AddPersistentExcludeApps
or-ape
: Adds applications to the persistent exclusion list.-RemovePersistentExcludeApps
or-rpe
: Removes applications from the persistent exclusion list.-CustomParams
or-cp
: Specifies custom parameters to pass directly to winget.-Help
: Displays detailed help for the script.
normal
: Default mode, interactive update.silent
: Silent mode, automatically accepts all agreements.force
: Forced mode, ignores version checks and bypasses some restrictions.verbose
: Provides detailed logging information.no-interaction
: Runs without user interaction, suitable for automated scripts.full-upgrade
: Includes unknown versions and pinned packages in the upgrade.safe-upgrade
: Performs a conservative upgrade, accepting only package agreements.
.\winget-update.ps1
.\winget-update.ps1 -ExcludeApps "App1,App2" -Mode silent
.\winget-update.ps1 -AddPersistentExcludeApps "App3,App4"
.\winget-update.ps1 -Mode force -CustomParams "--no-upgrade"
Contributions are welcome! Feel free to open an issue or submit a pull request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT Licence. See the LICENCE file for details.
Developed with ❤️ by Sterbweise