Verify and install multiple packages from a package list.
A PowerShell script that allows the user to install multiple packages using the Windows Package Manager (winget).
The Windows Package Manager is an open source client designed for command-line usage.
winget install
is unable to read multiple programs as positional argumentswinget upgrade
is unable to selectively upgrade a handful of packages
This script asynchronously verifies the given package identifiers with a winget show
query. If the given packages are valid, it then sequentially installs programs that are not already installed. In the case where a given program is already installed, the script will upgrade it only if a later version exists; otherwise, the upgrade is skipped.
- Update 'winget-upgrade.json' with the exact package identifier (case-sensitive), found using
winget search
.
For example,winget search --moniker git
results in finding 'Git.Git'. Therefore, the json would be as follows.
{
"programs": [
"Git.Git"
]
}
- In PowerShell 5.1 (admin) or later, run the following command:
.\winget-upgrade.ps1
- Create logger
- Optimize successive runs by remembering recent package ID validations
- Install/upgrade a number of packages in parallel
- Install/upgrade by giving arguments instead of json
- Convert script into module
- Unfortunately, using winget to install some programs (e.g. Visual Studio, Microsoft Teams, LibreOffice) triggers an automatic system restart. See here to follow the GitHub issue thread. Make sure to SAVE YOUR WORK before running any
winget {install,upgrade}
commands.