pin command (winget)

July 11, 2024 ยท View on GitHub

The winget pin command allows you to limit the Windows Package Manager from upgrading a package to specific ranges of versions, or it can prevent it from upgrading a package altogether. A pinned package may still upgrade on its own and be upgraded from outside the Windows Package Manager.

Pin Types

WinGet supports three types of package pins:

  • Pinning: The package is excluded from winget upgrade --all but allows winget upgrade <package>. You can use the --include-pinned argument to let winget upgrade --all include pinned packages.

  • Blocking: The package is blocked from winget upgrade --all or winget upgrade <package>, you will have to unpin the package to let WinGet perform an upgrade. The --force option can be used to override the pin's behavior.

  • Gating: The package is pinned to a specific version or version range. You can specify an exact version you want a package to be pinned to or you can utilize the wildcard character * as the last version part to specify a version range. For example, if a package is pinned to version 1.2.*, any version between 1.2.0 to 1.2.x is considered valid. The --force option can be used to override the pin's behavior.

Usage

winget pin <subcommand> <options>

Options

The following options are available.

OptionDescription
-?, --helpGets additional help on this command.
--waitPrompts the user to press any key before exiting.
--logs,--open-logsOpen the default logs location.
--verbose, --verbose-logsUsed to override the logging setting and create a verbose log.
--nowarn,--ignore-warningsSuppresses warning outputs.
--disable-interactivityDisable interactive prompts.
--proxySet a proxy to use for this execution.
--no-proxyDisable the use of proxy for this execution.

Subcommands

The pin command supports the following subcommands.

SubcommandDescription
addAdd a new pin.
removeRemove a package pin.
listList current pins.
resetReset pins

add

The add subcommand adds a new pin. This subcommand requires that you specify the exact package to pin. If there is any ambiguity, you will be prompted to further filter the add subcommand to an exact application.

Usage:

winget pin add [[-q] <query>] [<options>]

Arguments

ArgumentDescription
-q,--queryThe query used to search for an app.

Options

The options allow you to customize adding pins to meet your needs.

OptionDescription
--idLimits the search to the ID of the application.
--nameLimits the search to the name of the application.
--monikerLimits the search to the moniker listed for the application.
--tagLimits the search to the tag listed for the application.
--cmd, --commandLimits the search to the command of the application.
-e, --exactUses the exact string in the query, including checking for case-sensitivity. It will not use the default behavior of a substring.
-v, --versionEnables you to specify an exact version to pin. The wildcard * can be used as the last version part. Changes pin behavior to be gating.
-s, --sourceRestricts the search to the source name provided. Must be followed by the source name.
--headerOptional Windows-Package-Manager REST source HTTP header.
--authentication-modeSpecify authentication window preference (silent, silentPreferred or interactive).
--authentication-accountSpecify the account to be used for authentication.
--accept-source-agreementsUsed to accept the source license agreement, and avoid the prompt.
--forceDirect run the command and continue with non security related issues.
--blockingBlock from upgrading until the pin is removed, preventing override arguments. Changes pin behavior to be blocking.
--installedPin a specific installed version
-?, --helpGet additional help on this command.
--waitPrompts the user to press any key before exiting.
--logs, --open-logsOpen the default logs location.
--verbose, --verbose-logsUsed to override the logging setting and create a verbose log.
--nowarn,--ignore-warningsSuppresses warning outputs.
--disable-interactivityDisable interactive prompts.
--proxySet a proxy to use for this execution.
--no-proxyDisable the use of proxy for this execution.

Examples

The following example adds a pin for an application. Adding this pin will prevent this package from being upgraded when calling winget upgrade --all. Use the --include-pinned argument with winget upgrade --all to include any pinned packages.

winget pin add powertoys

The following example adds a blocking pin for an application using its ID. Adding a blocking pin will prevent this package from being upgraded when calling winget upgrade --all or winget upgrade <package>. You will need to unblock the package to let WinGet perform an upgrade.

winget pin add --id Microsoft.PowerToys --blocking

The following example adds a gating pin for an application using its ID. Adding a gating pin will prevent upgrades that upgrade the package version outside of a specific version or the gated wildcard range.

winget pin add --id Microsoft.PowerToys --version 0.70.*

remove

The remove subcommand removes a pin. This subcommand requires that you specify the exact package pin to remove. If there is any ambiguity, you will be prompted to further filter the remove subcommand to an exact application.

Usage:

winget pin remove [[-q] <query>] [<options>]

Arguments

ArgumentDescription
-q,--queryThe query used to search for an app.

Options

The options allow you to customize removing pins to meet your needs.

OptionDescription
--idLimits the search to the ID of the application.
--nameLimits the search to the name of the application.
--monikerLimits the search to the moniker listed for the application.
-s, --sourceRestricts the search to the source name provided. Must be followed by the source name.
--tagLimits the search to the tag listed for the application.
--cmd, --commandLimits the search to the command of the application.
-e, --exactUses the exact string in the query, including checking for case-sensitivity. It will not use the default behavior of a substring.
--headerOptional Windows-Package-Manager REST source HTTP header.
--authentication-modeSpecify authentication window preference (silent, silentPreferred or interactive).
--authentication-accountSpecify the account to be used for authentication.
--accept-source-agreementsUsed to accept the source license agreement, and avoid the prompt.
--installedPin a specific installed version.
-?, --helpGet additional help on this command.
--waitPrompts the user to press any key before exiting.
--logs, --open-logsOpen the default logs location.
--verbose, --verbose-logsUsed to override the logging setting and create a verbose log.
--nowarn,--ignore-warningsSuppresses warning outputs.
--disable-interactivityDisable interactive prompts.
--proxySet a proxy to use for this execution.
--no-proxyDisable the use of proxy for this execution.

Examples

The following example removes a pin for an application.

winget pin remove powertoys

The following example removes a pin for an application using its ID.

winget pin remove --id Microsoft.PowerToys

list

The list subcommand lists all current pins.

Usage:

winget pin list [[-q] <query>] [<options>]

Arguments

ArgumentDescription
-q,--queryThe query used to search for an app.

Options

The options allow you to customize listing pins to meet your needs.

OptionDescription
--idLimits the search to the ID of the application.
--nameLimits the search to the name of the application.
--monikerLimits the search to the moniker listed for the application.
-s, --sourceRestricts the search to the source name provided. Must be followed by the source name.
--tagLimits the search to the tag listed for the application.
--cmd, --commandLimits the search to the command of the application.
-e, --exactUses the exact string in the query, including checking for case-sensitivity. It will not use the default behavior of a substring.
--headerOptional Windows-Package-Manager REST source HTTP header.
--authentication-modeSpecify authentication window preference (silent, silentPreferred or interactive).
--authentication-accountSpecify the account to be used for authentication.
--accept-source-agreementsUsed to accept the source license agreement, and avoid the prompt.
-?, --helpGet additional help on this command.
--waitPrompts the user to press any key before exiting.
--logs, --open-logsOpen the default logs location.
--verbose, --verbose-logsUsed to override the logging setting and create a verbose log.
--nowarn,--ignore-warningsSuppresses warning outputs.
--disable-interactivityDisable interactive prompts.
--proxySet a proxy to use for this execution.
--no-proxyDisable the use of proxy for this execution.

Examples

The following example lists all current pins.

winget pin list

The following example lists a specific package pin.

winget pin list --id Microsoft.PowerToys

reset

The reset subcommand resets all pins.

Using this subcommand without the --force argument will show the pins that would be removed.

To reset all pins, include the --force argument.

Usage:

winget pin reset [<options>]

Options

The options allow you to customize reseting pins to meet your needs.

OptionDescription
--forceDirect run the command and continue with non security related issues.
-s, --sourceRestricts the search to the source name provided. Must be followed by the source name.
-?, --helpGet additional help on this command.
--waitPrompts the user to press any key before exiting.
--logs, --open-logsOpen the default logs location.
--verbose, --verbose-logsUsed to override the logging setting and create a verbose log.
--nowarn,--ignore-warningsSuppresses warning outputs.
--disable-interactivityDisable interactive prompts.
--proxySet a proxy to use for this execution.
--no-proxyDisable the use of proxy for this execution.

Examples

The following example shows all pins that would be reset.

winget pin reset

The following example resets all existing pins.

winget pin reset --force