Using the preview version of the WinGet PowerShell Module

I’ve been using the WinGet command-line version for quite some time now, and I am pleased with the apt-get-like installation method for installing/updating/removing software on my Windows machines. (WinGet is also the new Windows Store installation option for Microsoft Intune.) But there’s also a PowerShell module for WinGet, still in preview but very functional already. I will show you how to use that module in this blog post.

What is WinGet?

“The winget command line tool enables users to discover, install, upgrade, remove, and configure applications on Windows 10 and Windows 11 computers. This tool is the client interface to the Windows Package Manager service.”

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

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

Note: This only works in PowerShell 7

Using the WinGet PowerShell Module

After installing and importing the module, these commands are available:

Add-WinGetSource

This cmdlet adds a new source that you can use to install packages from, used for adding private repositories.

Assert-WinGetPackageManager

This cmdlet checks WinGet files for the latest (preview) version.

Disable-WinGetSetting

Disables Winget settings specified with the -Name parameter. Currently, only LocalManifestFiles is supported.

Enable-WinGetSetting

Enables Winget settings specified with the -Name parameter. Currently, only LocalManifestFiles is supported.

Find-WinGetPackage

This can be used to search for packages. You can use the -Exact parameter if you know the full name (7zip.7zip, for example) or the -ID parameter for a specific match. Without specifying a specific parameter, the -Name one is used. For example, running this:

Find-WinGetPackage Adobe

Name Id Version Match Source
---- -- ------- ----- ------
Adobe Express 9P94LH3Q1CP5 Unknown Id: msstore
Adobe Lightroom 9PNLG4ZG0XGJ Unknown Id: msstore
Adobe Acrobat Reader DC XPDP273C0XHQH2 Unknown Id: msstore
Adobe Fresco XP8C8R0ZKZR27V Unknown Id: msstore
Adobe Creative Cloud XPDLPKWG9SW2WD Unknown Id: msstore
Adobe Photoshop Express 9WZDNCRFJ27N Unknown Id: msstore
Adobe Experience Manager Forms 9ND12RLXTGTT Unknown Id: msstore
Adobe Content Viewer 9WZDNCRFJBZ1 Unknown Id: msstore
Adobe Photoshop Express Toshiba… 9WZDNCRDFSG4 Unknown Id: msstore
Avocode Avocode.Avocode 4.15.6 Tag: adobe winget
Adobe Acrobat Reader DC (64-bit) Adobe.Acrobat.Reader.64-bit 23.001.20064 Tag: adobe winget
Adobe Acrobat Reader DC Adobe.Acrobat.Reader.32-bit 23.001.20064 Tag: adobe winget
Adobe DNG Converter Adobe.DNGConverter 15.0.0 Id: Adobe.DNGConverter winget
Cryptr Adobe.Cryptr 0.5.0 Id: Adobe.Cryptr winget
Brackets Adobe.Brackets 1.14.17770 Id: Adobe.Brackets winget
Adobe Connect Adobe.AdobeConnect 21.11.22 Id: Adobe.AdobeConnect winget

Get-WinGetPackage

This will return all WinGet-compatible software from your system in a list. A small part of the output from my system:

Name Id Version Available Source
---- -- ------- --------- ------
7-Zip 7zip.7zip 22.01 winget
Brave Brave.Brave 111.1.49.128 winget
Ubuntu 20.04 LTS Canonical.Ubuntu.2004 2004.2022.8.0 winget
Cisco AnyConnect Secure Mobilit… Cisco AnyConnect Secure Mobility Client 4.10.05111
Citrix Workspace Citrix.Workspace 23.2.0.38 winget
Clipchamp Clipchamp.Clipchamp_yxz26nhyzhsrt 2.5.15.0
Dolby Access DolbyLaboratories.DolbyAccess_rz1tebttyb220 3.16.352.0
Dolby Audio Speaker System DolbyLaboratories.DolbyAudioSpeakerSystem_rz1tebttyb220 3.30201.210.0
GitHub Desktop GitHub.GitHubDesktop 3.2.0 winget
Git Git.Git 2.40.0 winget
Grammarly for Windows Grammarly.Grammarly 1.0.27.421 winget
Graphviz Graphviz.Graphviz 7.1.0
.......

Get-WinGetSource

Displays all the sources that are currently configured. In my case, it returned this:

Name Argument Type
---- -------- ----
msstore https://storeedgefd.dsx.mp.microsoft.com/v9.0 Microsoft.Rest
winget https://cdn.winget.microsoft.com/cache Microsoft.PreIndexed.Package

Get-WinGetUserSettings

Displays the configured user settings.

Get-WinGetVersion

Shows the version of WinGet, v1.4.10173, in this case.

Install-WinGetPackage

Installs software using Winget. If you want to install VLC, the syntax is as follows:

Install-WinGetPackage VideoLAN.VLC

Output on the screen is as follows:

C:\Users\HarmVeenstra> Install-WinGetPackage VideoLAN.VLC

CorrelationData :
ExtendedErrorCode :
InstallerErrorCode : 0
RebootRequired : False
Status : Ok
NativeObject : WinRT.ObjectReference`1[WinRT.Interop.IUnknownVftbl]
HasUnwrappableNativeObject : True
AdditionalTypeData : {}

This information shows that the installation was successful, no reboot was required, and the ErrorCode (If you want to monitor it) was 0.

Remove-WinGetSource

If you added a specific Source, you could remove it using Remove-WingetSource -Name xxxx.

Repair-WinGetPackageManager

Repairs WinGet for the Current or All Users.

Reset-WinGetSource

To reset the list of Sources, you can run Reset-WingetSource without any parameters to reset it back to default. Only that Source would be removed if a specific Source was specified in the -Name parameter.

Uninstall-WinGetPackage

This can be used to uninstall a specific package. In the example below, I used this to uninstall the VLC player.

C:\Users\HarmVeenstra> Uninstall-WinGetPackage -ID VideoLAN.VLC

CorrelationData :
ExtendedErrorCode :
RebootRequired : False
Status : Ok
UninstallerErrorCode : 0
NativeObject : WinRT.ObjectReference`1[WinRT.Interop.IUnknownVftbl]
HasUnwrappableNativeObject : True
AdditionalTypeData : {}

The information shows that the uninstall was successful, no reboot was required, and the ErrorCode (If you want to monitor it) was 0.

Update-WinGetPackage

This will update a specific WinGet package or all WinGet packages on your system. In the example below, I updated NotePad++ because I knew that that was an update for that. Running Update-WingetPackage doesn’t update all packages automatically yet #Preview

C:\Users\HarmVeenstra> Update-WinGetPackage Notepad++.Notepad++

CorrelationData :
ExtendedErrorCode :
InstallerErrorCode : 0
RebootRequired : False
Status : Ok
NativeObject : WinRT.ObjectReference`1[WinRT.Interop.IUnknownVftbl]
HasUnwrappableNativeObject : True
AdditionalTypeData : {}

This information shows that the update was successful, no reboot was required, and the ErrorCode (If you want to monitor it) was 0.

Conclusion

The preview version of the WinGet PowerShell module is already usable, but it’s not perfect yet. I will monitor future updates and update this blog post when there’s more to report. 🙂

One thought on “Using the preview version of the WinGet PowerShell Module

  1. Pingback: Intune Newsletter - 31st March 2023 - Andrew Taylor

Leave a Reply

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