Skip to content
Menu

Update Apps With Winget

Lists applications with an upgrade available through winget and upgrades each on its own, skipping excluded ids, a built-in never-upgrade list and detected running apps unless Force is true.

Update apps with winget is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Update apps with winget. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1, administrator rights, winget (App Installer), internet access
Changes thingsChanges what it runs on

What It Does

The script finds winget, App Installer, the way SYSTEM can run it: it tries the newest App Installer copy under Program Files\WindowsApps first and can fall back to another runnable copy or winget.exe on PATH. If no copy starts, the run is SKIPPED. The script never installs winget.

It lists the applications with an upgrade available, drops the ones in ExcludeIds and a built-in never-upgrade list, then upgrades each remaining application on its own with winget upgrade --id and the exact, silent and agreement switches, with prompts off. The built-in list covers RMM and remote-support agents such as ScreenConnect, TeamViewer, AnyDesk and Splashtop, virtual-machine guest tools such as QEMU, VirtIO, SPICE and UTM, VMware Tools and Hyper-V, and Microsoft.AppInstaller, which would replace winget itself in the middle of the run.

Each application is one row, and one failing application does not stop the others. The run ends in ERROR naming the ones that failed. After an upgrade it lists again and warns if an app it attempted still shows as upgradable or if the verification list cannot be read. When somebody is signed in, an application that appears to be running for them is skipped and listed, because a silent installer can close it, unless Force is true. A winget process that runs longer than TimeoutMinutes is stopped. If winget cannot list upgrades, the run ends in ERROR rather than saying it is up to date. A winget result that means restart needed counts as success and is reported.

As SYSTEM, winget sees machine-wide applications only, and per-user installs are not listed. It never changes applications that are not in winget's list, and it never reboots. MaxChanges, optional, refuses to run when more applications than that would be upgraded.

Before You Run It

  • Run it with DryRun=true first and read the list of applications it would upgrade.
  • Schedule it outside working hours. An installer may close a running copy of its application.
  • Put any application whose version you must hold into ExcludeIds.
  • Check that winget (App Installer) is present on the PCs. The script does not install it.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
  • What it changes: Upgrades each application winget lists as upgradable.
  • Restart: It never restarts the machine itself. When a restart is needed to finish, the answer says so.
  • Typical run: 1 to 30 minutes.
  • Example answer: "Upgraded 3 of 3 winget apps: Git.Git, 7zip.7zip, VideoLAN.VLC"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • ExcludeIds: Winget package Ids never to upgrade, comma or semicolon separated; * and ? work (for example Google.Chrome;Mozilla.*). Default empty.
  • Force: true to upgrade applications that appear to be running for the signed-in user (their windows close). Default false.
  • TimeoutMinutes: How long to wait for each application's upgrade. Whole number, 1 to 240. Default 30.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

update-winget-apps.ps1 · 1021 lines · 52 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.