Using the PowerShell WinGet module

In March 2023, I wrote a blog post about the Preview version of the WinGet module. Since then, it has undergone many updates, and in this (long) blog post, I will show you how to use Microsoft.WinGet.Client PowerShell Module.

What is WinGet?

WinGet is a command line tool enabling users to discover, install, upgrade, remove and configure applications on Windows 10, Windows 11, and Windows Server 2025 computers. This tool is the client interface to the Windows Package Manager service.”

Source: https://learn.microsoft.com/en-us/windows/package-manager/winget/

What is the Microsoft.WinGet.Client Module?

This PowerShell module allows you to use the WinGet command line tool with cmdlets. It also has some excellent features to help you install or maintain your WinGet installation.

The Cmdlets that you can use are:

Note: For the cmdlets of the Microsoft.WinGet.Client module to work, you do need a working WinGet command line tool on your system. Check the Repair-WinGetPackageManager chapter if it’s not installed on your system. Still, in a recent Windows Client operating system, it should be there by default (It’s even available on Windows Server 2025 now!)

How to install the WinGet PowerShell module

In the early preview versions, you had to install the module by downloading the files and importing them manually. This has changed to the standard installation method, and you can install it now by running the following:

Install-Module -Name Microsoft.WinGet.Client
Import-Module -Name Microsoft.WinGet.Client

Microsoft.WinGet.Client module cmdlets

Add-WinGetSource

You can use this to add new WinGet source locations for your packages. WinGet lets you use your own internal or secure location for private packages. You can use this for example:

Add-WinGetSource -Name mysource -Argument https://interal.powershellisfun.com/ -Type Microsoft.Rest

I could not find any information about different types of Microsoft.Rest is mentioned in the examples, but I couldn’t find reference data for that. The type that is returned by running Get-WingetSource is Microsoft.Rest (msstore) and Microsoft.PreIndexed.Package (winget).

Assert-WinGetPackageManager

This will verify if WinGet is installed correctly. It can be used with three parameters:

  • -Latest This will check if the installed WinGet version is compatible with the installed Microsoft.WinGet.Client module will return nothing/no error if that’s the case. In my case, because I’m running a Preview version, it returned this:

  • -IncludePreRelease If the WinGet version is compatible with the installed Microsoft.WinGet.Client module, the cmdlet will return nothing/no error.
  • -Version You can specify to check for a specific version, for example, Assert-WinGetPackageManager -Version v1.8.1911. If it’s compatible, it will return nothing/no error.

Disable-WinGetSetting

This can be used to disable an Administrative setting and must be run as an Administrator. It has five values that you can use for the -Name Parameter:

  • – BypassCertificatePinningForMicrosoftStore This will disable Microsoft Store certificate checking; this should be avoided because of the risk of Man-in-the-Middle attacks. (But it might be helpful during testing/development as a temporary thing)
  • – InstallerHashOverride This will disable the Hash check during installation, which could be helpful when packages are updated and the Manifest isn’t updated.
  • – LocalArchiveMalwareScanOverride This will disable scanning a local Manifest file, which might be helpful in private sources.
  • – LocalManifestFiles This will disable the use of local Manifest files.
  • – ProxyCommandLineOptions This will allow you to disable supplying Proxy options.

For example (I used -Verbose because it doesn’t display anything if the command executes successfully):

Enable-WinGetSetting

This can enable an administrative setting and must be run by an administrator. It has five values that you can use for the -Name Parameter:

  • BypassCertificatePinningForMicrosoftStore This will enable Microsoft Store certificate checking.
  • InstallerHashOverride This will enable the Hash check during installation.
  • LocalArchiveMalwareScanOverride This will enable the scanning of a local Manifest file.
  • LocalManifestFiles This will enable the use of local Manifest files.
  • ProxyCommandLineOptions This will enable you to supply proxy options.

For example (I used -Verbose because it doesn’t display anything if the command executes successfully):

Export-WinGetPackage

This will allow you to download a WinGet package from a configured source. It will download the package, manifest, and its dependencies. The parameters for the cmdlet are:

  • -AllowHashMisMatch lets you download the package even when the SHA256 hash does not match the package manifest.
  • -Architecture You can specify the processor architecture for the WinGet package installer. The values are Arm, Arm64, Default, X64, or X86.
  • -DownloadDirectory Specify the download directory. The default is the user’s Downloads folder.
  • -Id You can specify the WinGet package identifier, such as Notepad++.Notepad++
  • -InstallerType Use this to specify the type. Values are: Default, Inno, Wix, Msi, Nullsoft, Zip, Msix, Exe, Burn, MSStore and Portable
  • -Locale Use this to specify the locale. For example, en-US of nl-NL.
  • -MatchOption This specifies the match option when querying packages. Values are Equals, EqualsCaseInsentitive, StartWithCaseInsensitive, ContainsCaseSensitive
  • -Moniker Specify the moniker of the WinGet package to download. For example, the moniker for the Microsoft.PowerShell package is pwsh
  • -Name Specify the name of the WinGet package to export
  • -PSCatalogPackage You can specify the PSCatalogPackage object, which can be found using Find-WinGetPackage
  • -Query Use one or more strings to search for it in the WinGet package. It will search for matching strings in PackageName, PackageIdentifier, Moniker, or Tags
  • -Scope Specify the WinGet package installer scope. Values are Any, User, System, UserOrUnknown, SystemOrUnkown
  • -SkipDependencies Use this so that the WinGet package dependencies are not downloaded.
  • -Source Use this to specify the source location
  • -Version Specify the version of the WinGet package to be downloaded

For example:

This exported Notepad++ to my Downloads folder:

Next to the installation file, there’s also the corresponding .yaml file that WinGet uses:

Find-WinGetPackage

You can use this to search for packages from the configured resources. Parameters are:

  • -Command Specify the name of the command in the package manifest.
  • -Count: Use this to specify the maximum number of results to return.
  • -Id You can specify the WinGet package identifier, such as Notepad++.Notepad++
  • -MatchOption This specifies the match option when querying packages. Values are Equals, EqualsCaseInsentitive, StartWithCaseInsensitive, ContainsCaseSensitive
  • -Moniker Specify the moniker of the WinGet package to download. For example, the moniker for the Microsoft.PowerShell package is pwsh
  • -Name Specify the name of the WinGet package to search for
  • -Query Use one or more strings to search for. It will search for matching strings in PackageName, Moniker, or Tags
  • -Source Use this to specify the source location. Familiar sources are msstore and winget
  • -Tag Specify a package tag to search for

For example:

Get-WinGetPackage

This will list all the packages installed on your system from WinGet sources and other methods. Packages installed using MSIX or ARP can’t be correlated to WinGet. Parameters are:

  • -Command Specify the name of the command in the package manifest.
  • -Count: Use this to specify the maximum number of results to return.
  • -Id You can specify the WinGet package identifier, such as Notepad++.Notepad++
  • -MatchOption This specifies the match option when querying packages. Values are Equals, EqualsCaseInsentitive, StartWithCaseInsensitive, ContainsCaseSensitive
  • -Moniker Specify the moniker of the WinGet package to download. For example, the moniker for the Microsoft.PowerShell package is pwsh
  • -Name Specify the name of the WinGet package to search for
  • -Query Use one or more strings to search for. It will search for matching strings in PackageName, Moniker, or Tags
  • -Source Use this to specify the source location. Familiar sources are msstore and winget
  • -Tag Specify a package tag to search for

For example (The list is a lot longer 😀 )

Get-WinGetSetting

This will retrieve all the configured WinGet settings, including the schema, administrative settings, and the location of the user settings file. For example:

It has one Parameter, -AsPlainText. This will output the results in a JSON format like:

{"$schema":"https://aka.ms/winget-settings-export.schema.json","adminSettings":{"BypassCertificatePinningForMicrosoftStore":false,"InstallerHashOverride":false,"LocalArchiveMalwareScanOverride":false,"LocalManifestFiles":false,"ProxyCommandLineOptions":false},"userSettingsFile":"C:\\Users\\HarmVeenstra\\AppData\\Local\\Packages\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\LocalState\\settings.json"}

Get-WinGetSource

This will display all the configured WinGet Sources. The -Name Parameter can be used to specify a specific name. For example:

Get-WinGetUserSettings

This will display the WinGet settings for the current user; by default, these are stored in $env:LOCALAPPDATA\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json (This file will be created after setting the first option using Set-WinGetUserSetting)

For example:

This shows my user settings in which I configured the progress bar to show in a rainbow color scheme.

Get-WinGetVersion

This will show the installed version of WinGet. For example:

Install-WinGetPackage

This will install a WinGet package from a configured source. Parameters are:

  • -AllowHashMismatch Allows you to download a package even when the SHA256 hash for an installer or a dependency does not match the SHA256 hash in the WinGet package manifest.
  • -Architecture You can specify the processor architecture for the WinGet package installer. The values are Arm, Arm64, Default, X64, or X86.
  • -Custom This can pass additional arguments to the installer in a single string value.
  • -Force Force the installer to run even when other checks WinGet would perform would prevent this action.
  • -Header Custom value to be passed via HTTP header to WinGet REST sources.
  • -Id Specify the package identifier for which to search. The command does a case-insensitive full-text match rather than a substring match.
  • -InstallerType Use this to specify the type. Values are: Default, Inno, Wix, Msi, Nullsoft, Zip, Msix, Exe, Burn, MSStore and Portable
  • -Locale Use this to specify the locale. For example, en-US of nl-NL.
  • -Log Specify the location for the installer log. The value can be a fully-qualified or relative path and must include the file name. For example: $env:TEMP\package.log.
  • -MatchOption This specifies the match option when querying packages. Values are Equals, EqualsCaseInsentitive, StartWithCaseInsensitive, ContainsCaseSensitive.
  • -Mode Specify the installer’s output mode. Values are silent or interactive
  • -Moniker Specify the moniker of the WinGet package to download. For example, the moniker for the Microsoft.PowerShell package is pwsh
  • -Name Specify the name of the WinGet package to be installed.
  • -PSCatalogPackage Provide PSCatalogPackage object. You can get a PSCatalogPackage object by using the Find-WinGetPackage command.
  • -Scope Specify the WinGet package installer scope. Values are Any, User, System, UserOrUnknown, SystemOrUnkown
  • -SkipDependencies Use this so that the WinGet package dependencies are not downloaded.
  • -Source Use this to specify the source location
  • -Version Specify the version of the WinGet package to be downloaded.

For example, if you want to install Total Commander, you can run “Install-WinGetPackage -Id Ghisler.TotalCommander -Mode Silent

Remove-WinGetSource

This will remove a configured WinGet Source; by default, two sources are registered: msstore and winget. It must be run as an Administrator; the -Name is the only parameter. For example:

Repair-WinGetPackage

This will repair a WinGet package installation on your computer if the package supports that. Parameters are:

  • -Id Specify the package identifier for which to search. The command does a case-insensitive full-text match rather than a substring match.
  • -Log Specify the location for the installer log. The value can be a fully-qualified or relative path and must include the file name. For example: $env:TEMP\package.log.
  • -MatchOption This specifies the match option when querying packages. Values are Equals, EqualsCaseInsentitive, StartWithCaseInsensitive, ContainsCaseSensitive.
  • -Mode Specify the installer’s output mode. Values are silent or interactive
  • -Moniker Specify the moniker of the WinGet package to download. For example, the moniker for the Microsoft.PowerShell package is pwsh.
  • -Name Specify the name of the WinGet package to be installed.
  • -PSCatalogPackage Provide PSCatalogPackage object. You can get a PSCatalogPackage object by using the Find-WinGetPackage command.
  • -Query Use one or more strings to search for. It will search for matching strings in PackageName, Moniker, or Tags
  • -Source Use this to specify the source location
  • -Version Specify the version of the WinGet package that needs to be repaired.

For example:

It doesn’t always support uninstall, or it could fail. Your mileage might vary 🙂

Repair-WinGetPackager

This will repair an existing installation of WinGet or install it on your system if not already present, and this is a great way to install it in your Windows Sandbox installation 🙂 Parameters are:

  • -AllUsers Use this parameter to repair the WinGet client for all user accounts on the computer. The command must be run with administrator permissions.
  • -IncludePreRelease Use this parameter to include prerelease versions of the WinGet client.
  • -Latest Use this parameter to install the latest version of the WinGet client.
  • -Version Use this parameter to specify the specific version of the WinGet client to install.

For example, this is the output when I ran it in a Windows Sandbox VM that didn’t have WinGet installed:

It downloads all the installation files and installs them, and the WinGet client is available for use, and all the cmdlets will work now, too:

Reset-WinGetSource

This will reset a WinGet source by removing it from the source configuration. The Parameters are:

  • -All This will reset all sources and add the default sources (msstore and winget).
  • -Name You can specify a specific one here.

For example, to reset the WinGet source, you can run Reset-WinGetSource -Name winget -Verbose (I added -Verbose because it won’t return any information if successful)

Set-WinGetUserSetting

You can use this to configure user settings for WinGet, which are stored in $env:LOCALAPPDATA\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json (This file will be created after setting the first option using Set-WinGetUserSetting). Parameters are:

  • -Merge By default, the command overwrites the current setting with the values provided. Use this parameter to append the new settings to the existing configuration.
  • -UserSettings A hashtable containing the key-value pairs representing the WinGet settings

The available settings are documented here: https://github.com/microsoft/winget-cli/blob/master/doc/Settings.md

For example, as mentioned in the Get-WinGetUserSetting chapter, you can configure the progress bar to be in a rainbow color scheme like this:

Test-WinGetUserSetting

This will allow you to test if a specific setting is active in WinGet user settings. Parameters are:

  • -IgnoreNotSet When you use the IgnoreNotSet parameter, the command only tests the provided values and doesn’t include other WinGet settings in the comparison.
  • -UserSettings A hashtable containing the key-value pairs representing the WinGet settings.

For example, to test the rainbow color scheme, you would use this:

Uninstall-WinGetPackage

You can use this to uninstall a package that was installed using WinGet. Parameters are:

  • -Id Specify the package identifier for which to search. The command does a case-insensitive full-text match rather than a substring match.
  • -Log Specify the location for the installer log. The value can be a fully-qualified or relative path and must include the file name. For example: $env:TEMP\package.log.
  • -MatchOption This specifies the match option when querying packages. Values are Equals, EqualsCaseInsentitive, StartWithCaseInsensitive, ContainsCaseSensitive.
  • -Mode Specify the installer’s output mode. Values are default, silent, or interactive
  • -Moniker Specify the moniker of the WinGet package to download. For example, the moniker for the Microsoft.PowerShell package is pwsh.
  • -Name Specify the name of the WinGet package that needs to be uninstalled.
  • -PSCatalogPackage Provide PSCatalogPackage object. You can get a PSCatalogPackage object by using the Find-WinGetPackage command.
  • -Query Use one or more strings to search for. It will search for matching strings in PackageName, Moniker, or Tags
  • -Source Use this to specify the source location
  • -Version Specify the version of the WinGet package that needs to be uninstalled.

For example, uninstalling Total Commander would look like this:

I did use the Silent option, but it still prompted me for uninstallation (If I wanted to keep configuration files, for example)

Update-WinGetPackage

This will update the WinGet software installed on your computer. Parameters are:

  • -AllowHashMismatch Allows you to download a package even when the SHA256 hash for an installer or a dependency does not match the SHA256 hash in the WinGet package manifest.
  • -Architecture You can specify the processor architecture for the WinGet package installer. The values are Arm, Arm64, Default, X64, or X86.
  • -Custom This can pass additional arguments to the installer in a single string value.
  • -Force Force the installer to run even when other checks WinGet would perform would prevent this action.
  • -Header Custom value to be passed via HTTP header to WinGet REST sources.
  • -Id Specify the package identifier for which to search. The command does a case-insensitive full-text match rather than a substring match.
  • -IncludeUnknown Use this parameter to upgrade the package when the installed version is not specified in the registry
  • -InstallerType Use this to specify the type. Values are: Default, Inno, Wix, Msi, Nullsoft, Zip, Msix, Exe, Burn, MSStore and Portable
  • -Locale Use this to specify the locale. For example, en-US of nl-NL.
  • -Location Specify the file path where you want the packed installed. The installer must be able to support alternate install locations.
  • -Log Specify the location for the installer log. The value can be a fully-qualified or relative path and must include the file name. For example: $env:TEMP\package.log.
  • -MatchOption This specifies the match option when querying packages. Values are Equals, EqualsCaseInsentitive, StartWithCaseInsensitive, ContainsCaseSensitive.
  • -Mode Specify the output mode for the installer; values are default, silent, and interactive.
  • -Moniker Specify the moniker of the WinGet package to download. For example, the moniker for the Microsoft.PowerShell package is pwsh
  • -Name Specify the name of the WinGet package to be installed.
  • -Override Use this parameter to override the existing arguments passed on to the installer. The parameter takes a single string value. To add multiple arguments, include the arguments in the string. The arguments must be provided in the format expected by the installer
  • -PSCatalogPackage Provide PSCatalogPackage object. You can get a PSCatalogPackage object by using the Find-WinGetPackage command.
  • -Scope Specify the WinGet package installer scope. Values are Any, User, System, UserOrUnknown, SystemOrUnkown
  • -SkipDependencies Use this so that the WinGet package dependencies are not downloaded.
  • -Source Use this to specify the source location
  • -Version Specify the version of the WinGet package to be downloaded.

You can use Get-WinGetPackage and Update-WinGetPackage, for example, together to update all WinGet-installed software like this: Get-WinGetPackage | Where-Object Source -eq winget | Update-WinGetPackage. This will look like:

As you can see in the Status column, Git was updated successfully, Teams had an install error (System-Wide installer for Teams Classic), and the others had no applicable upgrade.

Wrapping up

In the blog post, I showed all the cmdlets from the Microsoft WinGet.Client PowerShell module. It has dramatically improved since my blog post about the Preview version in 2023. I love the Repair-WinGetPackageManager cmdlet; it makes installing WinGet on a system so much easier!

5 thoughts on “Using the PowerShell WinGet module

  1. I need to use this in the system context, any workaround?

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.
    Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows PS C:\WINDOWS\system32> whoami nt authority\system PS C:\WINDOWS\system32> $env:Path = “C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps”
    PS C:\WINDOWS\system32> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

    Name Version Source Summary
    —- ——- —— ——-
    nuget 2.8.5.208 https://cdn.o… NuGet provider for the OneGet meta-package manager

    PS C:\WINDOWS\system32> Install-Module -Name Microsoft.WinGet.Client -Force
    PS C:\WINDOWS\system32> Import-Module -Name Microsoft.WinGet.Client
    PS C:\WINDOWS\system32> Enable-WinGetSetting -Name BypassCertificatePinningForMicrosoftStore
    Enable-WinGetSetting : Specified method is not supported.
    At line:1 char:1
    + Enable-WinGetSetting -Name BypassCertificatePinningForMicrosoftStore
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Enable-WinGetSetting], NotSupportedException
    + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.WinGet.Client.Cmdlets.Cmdlets.EnableSettingCmdlet

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.