List all packages installed with winget
Asked Answered
R

6

11

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?

Ringsmuth answered 24/1, 2023 at 23:23 Comment(0)
P
14

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

Pellikka answered 25/1, 2023 at 0:27 Comment(4)
@Pellikka It's a little different from what you stated. It's showing packages that appear to have a matching entry (package manifest) in a configured source. The default sources are "winget" for the community repository and "msstore" for the Microsoft Store source. Additional REST sources could also be added.Candlewood
I appreciate the correction, @DemitriusNelon - please see my update.Pellikka
P.S., @DemitriusNelon: most Microsoft-originated packages show no value in the "source" column for me (rather than "msstore"), as of winget version 1.4.10173); yet some - e.g. Microsoft.OneDriive - do.Pellikka
That's correct. If the package was installed via WinGet from the Microsoft Store, the ID would look like a string of characters (like: 9NBLGGH4NNS1 - The App Installer which contains WinGet) and it would show a match with the "msstore" source. We're still working to improve matching.Candlewood
C
4

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.

Candlewood answered 2/2, 2023 at 20:47 Comment(3)
Thank you. So even with the proposed filter it wouldn't be possible to show packages installed by WinGet right?Ringsmuth
That's correct. WinGet tracks what it installed, but the user could make many changes to the machine without using WinGet, so it's not really a "reliable" mechanism for knowing how the machine got to its current state.Candlewood
This is a correct, and totally regrettable, answer.Siam
D
3

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

Dozier answered 19/4, 2023 at 17:53 Comment(1)
Unfortunately, this is not what my question is about. Imagine you are changing your workstation and want to install only what you have installed yourself. However, after you export ALL packages with winget source, you will end up with entries that were installed by default in the previous version of Windows, but are now considered to be harmful, incompatible or deprecated in the new version of Windows.Ringsmuth
S
2

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?

Siam answered 29/6, 2023 at 17:36 Comment(1)
Well, beware. That lists only those that have updates/upgrades available, per the current version you're running and when it checks for available updates. winget list lists all packages, as discussed above. I know you said this may be a "useful partial answer". It's not clear that you had in mind how limited the result may be. :-)Wilkie
A
2

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 ….

Atonal answered 8/8, 2023 at 21:26 Comment(0)
H
0

Winget is nothing more than a simple a way to get and install packages (any software with an installer) and to upgrade packages that are on your machine, regardless of how they were first installed. So, it can easily upgrade packages installed with winget, with Chocolatey, with MS Store, or directly using an MSI.

But winget does not keep any type of record on your machine when it installs or upgrades a package. Even trying to compare and combine output from choco list and the Registry Uninstall folder, there's no connection to winget.

My solution: Create a winget wrapper

Create a thin PowerShell wrapper of the winget command ((command winget).source) that maintains its own local catalog of packages it installed or uninstalled over time.

You can even point to the wrapper.ps1 by defining your own winget alias to override the winget command.

Simple and effective. You just need to remember to use that on new machines before starting your setup.

Alternative: Get-Installed

Unless you only ever install packages with winget, then even such a catalog may not be a complete picture of what's on your system. If you want to duplicate another machine (without creating a cloned image) then you need to include choco, msi, MS Store, and possibly other installers.

There is a Get-Installed PowerShell script that scans the Registry Uninstall folders (both 32 and 64 bit) and optionally apps installed by MS Store and generates a report.

I've used this many times in the past to accomplish what the OP wanted to do!

Hagan answered 6/8, 2024 at 20:7 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.