Skip to main content

Using winget to identify Apps to update, remove or install

What

winget is a command line tool to manage applications on the Windows 10 and 11 platform.

When/Why

We've already covered how to install, upgrade, and remove packages on our endpoints.  You'll find those articles Installing a Package with wingetUpgrading a Package with winget  and Uninstalling a Package with winget respectively.  But sometimes we are going to want to do things out of the box.  Maybe we just want information on what is installed in this manner.  Or maybe we want to know about all apps that are available for upgrade.  Or maybe we even want to uninstall something we didn't install in the first place.

How

Thankfully winget has a command that helps us with all these things.  The winget "list" command will by default show you all applications that can be managed with winget and also show you if any of them need updated.  The usage is simply winget list, but if we run it through FileWave (to feed a custom field for instance), we still need to acount for our pre-requisites:

# Get the path to winget.exe
$winget = (Get-ChildItem -Path "C:\Program Files\WindowsApps\" -Filter "winget.exe" -Recurse | Sort-Object -Property LastWriteTime | Select-Object -Last 1).FullName

# Get the directory that winget.exe is inside of
$wingetdir = Split-Path -Path $winget -Parent

# we change directory to this locale so we can run the winget command without the full path
cd $wingetdir

# adding the authorization acceptance here is superfluous if it has already been accepted, but it won't harm anything to include
.\winget.exe list

Output of the command will look something like this:

wingetcommandoutput.png