镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Update-WinGetPackage -WhatIf: Installs the update instead of saying what it would do #4622

Description

@schittli

Brief description of your issue

If one starts Update-WinGetPackage -WhatIf
then it installs the update instead of saying what it would do

Steps to reproduce

Just start Update-WinGetPackage -WhatIf for any package

Expected behavior

Of course, as is always the case with PowerShell: A CmdLet only shows what it would do.
(Do we need to explain this to Microsoft? I wonder that Microsoft does not have unit-tests for default parameters.)

Actual behavior

If one starts Update-WinGetPackage -WhatIf
then it installs the update instead of saying what it would do

Environment

Windows Package Manager v1.8.1791
Windows: Windows.Desktop v10.0.19045.2006
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.23.1791.0

Activity

  1. added
    Issue-BugIt either shouldn't be doing this or needs an investigation.
    PowerShellIssue related to WinGet PowerShell Module or cmdlet
    Command-UpgradeIssue related to WinGet Upgrade
    and removed
    Needs-TriageIssue needs to be triaged
    on Jul 8, 2024
  2. jdhitsolutions commented on Aug 9, 2024

    @jdhitsolutions

    This is also true of Install-WingetPackage. I ran install-wingetpackage git.git -Verbose -WhatIf and it installed Git . This is a MAJOR issue.

  3. jdhitsolutions commented on Aug 9, 2024

    @jdhitsolutions

    On a related note, commands like Repair-WingetPackageManager should also support -WhatIf because they are changing the state of the system. Commands should have decent verbose output so that if I run Repair-WingetPackageManager -verbose -whatIf I can see exactly what will change.

  4. denelon commented on Sep 6, 2024

    @denelon
    Collaborator

    For Update-WinGetPackage what would you expect the output to be?

    Something like:

    PS C:\> Update-WinGetPackage Microsoft.PowerShell -WhatIf
    What if: Update Microsoft.PowerShell version 7.4.4.0 to Microsoft PowerShell version 7.4.5.0

    Would you expect it to be the WinGet Package identifier "Microsoft.PowerShell", or the value in Apps and Features? In this case it would just be PowerShell.

  5. jdhitsolutions commented on Feb 7, 2025

    @jdhitsolutions

    This is still a MAJOR issue. It should not download anything, nor should it install anything if I pass -WhatIf. It should show the package name, the version to be installed and the source.

  6. dodexahedron commented on Mar 4, 2026

    @dodexahedron

    The cmdlet declares SupportsShouldProcess=true, but it absolutely does not support it.

    It literally just creates the command in ProcessRecord and then calls Update on it.

    There's a call to ShouldProcess in PackageCommand.cs. But it is not the standard ShouldProcess method, and the problem is here:

            /// <summary>
            /// Prompts the user if it should continue processing if possible.
            /// </summary>
            /// <param name="target">Message.</param>
            /// <returns>If the operation should continue.</returns>
            internal bool ShouldProcess(string target)
            {
                // If not on the main thread just continue.
                if (this.pwshThread != Thread.CurrentThread)
                {
                    return true;
                }
    
                return this.psCmdlet.ShouldProcess(target);
            }

    Since it's all done in async Tasks, the chance it happens on the foreground thread is effectively 0, so this method breaks things.

    Also, doing it there, in that several-layers-up base class loses the context of the ShouldProcess. I think that method itself just needs to go away and the ShouldProcess calls should be to the standard ShouldProcess method, performed in each leaf commandlet at the appropriate time. For Update-WinGetPackage, that'd be either before the call to command.Update or even before constructing the command in the first place...

    Otherwise, SupportsShouldProcess should be false, since it DoesntSupportShouldProcess as currently implemented.

  7. mwilsonin commented on Jun 29, 2026

    @mwilsonin

    I just found this module after seeing Demitrius Nelon (@denelon) speak at PSConfEU. I tried it out using -WhatIf and it updated my apps.

    Please recognize that this is a fundamental breach of trust with your users. Cmdlets run with -WhatIf must never change states. Please just set SupportsShouldProcess to false until this is resolved. This was reported almost two years ago.

  8. dodexahedron commented on Sep 24, 2026

    @dodexahedron

    Strongly agreed, mwilsonin

    Needless to say, it is a rather surprising and concerning behavior.

    Just for a general alternative to doing an Update-WinGetPackage -WhatIf, until/unless this gets fixed, you can instead do a Get-WinGetPackage | Where-Object IsUpdateAvailable to at least see what has updates available, though that isn't technically exactly the same operation.

  9. dodexahedron commented on Oct 4, 2026

    @dodexahedron

    It should show the package name, the version to be installed and the source.

    And maybe the files/folders that will be replaced, added, and removed, as well. And for exe installers which don't provide enough info, it could at least say what it is going to execute.

    And that all could be either just written directly to the success stream or, better/more helpfully, it could write out an object that has those properties but which has type format data that makes it only show a summary view by default, letting you inspect the lower-level details if you want/need to.

    And pleeeaaase make any such class public and non-sealed, with a public constructor or factory method, so other tools can derive from the type and remain compatible with the module.

    And pleeaaaase be pipeline-friendly (ideally accepting those very classes in an array) so we don't have to foreach-object everything output by the get-* commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Command-UpgradeIssue related to WinGet UpgradeIssue-BugIt either shouldn't be doing this or needs an investigation.PowerShellIssue related to WinGet PowerShell Module or cmdlet

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions