List all packages installed with winget

13.1k Views Asked by At

Is there a way to list only packages installed specifically with the winget command?

winget list

seems to show all packages installed on the machine.

I am changing my computer and I want to get a list of all packages I installed with winget to be installed on the new machine. Is this possible?

5

There are 5 best solutions below

4
mklement0 On

To narrow the display output to those packages available via winget, use the following:

(winget list) -match ' winget$'

Unfortunately, this isn't the same as those which you actually installed via winget,Tip of the hat to Demitrius Nelon:

  • As of version v1.4.10173 of winget, there is no way to get this information.

  • GitHub issue #1155 proposes future enhancements to winget list

3
Demitrius Nelon On

No, there is no way to have WinGet display packages it has installed.

The output of list is coming from the same source as "Windows Apps & Features". The filtering by source is just a request for displaying packages available in more than one source to the one specified.

An enhancement has been asked for to filter the results only to packages available in a given source.

1
Kyle K. On

You probably got your answer for this, but for those showing up via Google, here's a few current (as of 2023-04-19) helpful commands that work with Windows 10 (and I assume Windows 11).

As a side note, I never used WinGet to install anything on this PC, so it's nice that WinGet now shows apps that are compatible with WinGet even if they weren't installed with it.


WinGet Version Used: 1.5.441-preview

List Apps with Source = Winget: winget list --source "winget"

This gives you a filtered list in the terminal that have their source as "Winget". From what I can tell, any app that it can match an ID to in the repository is listed, regardless of how it was originally installed (nice!).

Side tip, you can export this list by piping the output to a file, example:

winget list --source "winget" > "C:\temp\__MyOutput.txt"

Export JSON Manifest of WinGet Programs winget export -o "C:\temp\__ListApps.txt"

This exports a JSON manifest that can be directly imported using the import command (example below). Change the "C:\temp__ListApps.txt" to whatever you wish. There are a few additional command options you can use: https://learn.microsoft.com/en-us/windows/package-manager/winget/export


Import JSON Manifest of WinGet Programs winget import -i "C:\temp\__ListApps.txt"

Use this to import that manifest for automated installation. Change the "C:\temp__ListApps.txt" to whatever you wish. Additional info: https://learn.microsoft.com/en-us/windows/package-manager/winget/import


There's also a lot of query functionality so you can filter the lists as you see fit, check the WinGet documentation here: https://learn.microsoft.com/en-us/windows/package-manager/winget/list

1
BobHy On

As noted above, the answer to your question remains "no", even to this very day.

However, this command shows the list of applications that winget can update, whether originally installed by winget or other means.

winget update

Maybe it's a useful partial answer?

0
Anthony Flores On

This is not perfect, but it's as close as I was able to get. I had the same objective as you. Trying to create a script that I could run on a new windows machine to install all my packages through winget.

In PowerShell run:

$winget_packages = ((winget list) -match ' winget$' | Select-String -Pattern "(?<= {2,})(?!\d+\.\d+)\S+(?= {2,})") | foreach {$_.Matches.Value}

$winget_script = (echo '@echo off

winget install ' ($winget_packages -replace "$", " ")
)

$winget_script | Set-Content install_winget_packages.bat -NoNewLine

Essentially what does this does is grab the list of installed programs with a "winget" source^1. It then takes the text preceded and followed by two or more spaces that is not a version number (X.X+) and gets the matched value into winget_packages^2.

Finally it puts winget install in front, adds a space at the end, and writes it all to a .bat file with the newlines collapsed.

1: As @DemitriusNelon points out this is not those you actually installed with winget, but I don't think that's much of a problem since I generally would rather they were if the source is available. In situations where I don't want this. I manually take those couple out.

2: This fails in cases where the package name is so long that there aren't two space but not long enough that it doesn't produce the error characters ….