Skip to main content
This guide walks you through installing and using the Windows Package Manager PowerShell modules.

Prerequisites

Before installing the PowerShell modules, ensure you have:
  • Windows 10 version 1809 or later, or Windows 11
  • PowerShell 7.2 or later
  • Windows Package Manager (WinGet) installed

Check PowerShell Version

Verify your PowerShell version:
$PSVersionTable.PSVersion
You should see version 7.2 or higher. If not, install PowerShell 7:
winget install Microsoft.PowerShell
Windows PowerShell (5.1) is not supported. You must use PowerShell 7.2 or later.

Installation

Install the WinGet PowerShell modules from the PowerShell Gallery:
# Install the client module for package management
Install-Module -Name Microsoft.WinGet.Client -Scope CurrentUser

# Install the configuration module
Install-Module -Name Microsoft.WinGet.Configuration -Scope CurrentUser

# Install the DSC module (optional)
Install-Module -Name Microsoft.WinGet.DSC -Scope CurrentUser

Import Modules

Import the modules to start using them:
Import-Module Microsoft.WinGet.Client
Import-Module Microsoft.WinGet.Configuration

Basic Usage

Search for Packages

Find packages in configured sources:
# Search by name
Find-WinGetPackage -Name "Visual Studio Code"

# Search by ID
Find-WinGetPackage -Id Microsoft.VisualStudioCode

# Search with query
Find-WinGetPackage -Query "python"

Install Packages

Install packages from sources:
# Install by ID
Install-WinGetPackage -Id Microsoft.PowerToys

# Install with specific version
Install-WinGetPackage -Id Microsoft.PowerToys -Version 0.70.0

# Install interactively
Install-WinGetPackage -Id Microsoft.PowerToys -Mode Interactive

List Installed Packages

View installed packages:
# List all installed packages
Get-WinGetPackage

# Find specific installed package
Get-WinGetPackage -Name "PowerToys"

# List from specific source
Get-WinGetPackage -Source winget

Update Packages

Update installed packages:
# Update specific package
Update-WinGetPackage -Id Microsoft.PowerToys

# Update to specific version
Update-WinGetPackage -Id Microsoft.PowerToys -Version 0.71.0

# Update all packages (use with Get-WinGetPackage)
Get-WinGetPackage | Where-Object { $_.IsUpdateAvailable } | Update-WinGetPackage

Uninstall Packages

Remove installed packages:
# Uninstall by ID
Uninstall-WinGetPackage -Id Microsoft.PowerToys

# Uninstall with force flag
Uninstall-WinGetPackage -Id Microsoft.PowerToys -Force

Working with Configuration Files

The configuration module enables declarative package management:
# Load a configuration file
$config = Get-WinGetConfiguration -File "C:\config.yaml"

# Get details about the configuration
Get-WinGetConfigurationDetails -Set $config

# Apply the configuration
Invoke-WinGetConfiguration -Set $config -AcceptConfigurationAgreements

Pipeline Support

Cmdlets support PowerShell pipeline operations:
# Find and install
Find-WinGetPackage -Id Microsoft.PowerToys | Install-WinGetPackage

# Get and update
Get-WinGetPackage -Id Microsoft.PowerToys | Update-WinGetPackage

# Find and examine
Find-WinGetPackage -Query "python" | Select-Object Name, Id, Version

Using WhatIf and Confirm

Test commands before executing:
# See what would be installed
Install-WinGetPackage -Id Microsoft.PowerToys -WhatIf

# Prompt for confirmation
Uninstall-WinGetPackage -Id Microsoft.PowerToys -Confirm

Common Parameters

Match Options

Control how package fields are matched:
# Exact match (case insensitive)
Find-WinGetPackage -Name "PowerToys" -MatchOption EqualsCaseInsensitive

# Contains match
Find-WinGetPackage -Name "Power" -MatchOption ContainsCaseInsensitive

# Starts with match
Find-WinGetPackage -Name "Power" -MatchOption StartsWithCaseInsensitive

Sources

Specify package sources:
# Search in specific source
Find-WinGetPackage -Id Microsoft.PowerToys -Source winget

# Install from specific source
Install-WinGetPackage -Id Microsoft.PowerToys -Source msstore

Error Handling

Handle errors in your scripts:
try {
    Install-WinGetPackage -Id Microsoft.PowerToys -ErrorAction Stop
    Write-Host "Package installed successfully"
}
catch {
    Write-Error "Failed to install package: $_"
}

Getting Help

Access built-in help for cmdlets:
# Get help for a cmdlet
Get-Help Install-WinGetPackage

# Get detailed help with examples
Get-Help Install-WinGetPackage -Detailed

# Get all examples
Get-Help Install-WinGetPackage -Examples

Next Steps

Install-WinGetPackage

Learn about package installation options

Configuration

Manage configuration files

DSC Resources

Use DSC for declarative configuration

Find-WinGetPackage

Search for packages

Build docs developers (and LLMs) love