Skip to content

Add ShouldProcess/ConfirmImpact to Uninstall-PSResource #433

Description

Look into adding a confirmation requirement when uninstalling a PSResource. Uninstall-Module does not do it, and maybe we should not do it for Uninstall-PSResource when a single specific module is uninstalled. But since Uninstall-PSResource handles Name wild card characters, we may want to prompt for confirmation in that case.

Uninstall-PSResource MyModule        #No confirmation prompt

Uninstall-PSResource *                         #Prompt for confirmation before uninstalling all modules.
Uninstall-PSResource * -Force              #No confirmation
Uninstall-PSResource * -Confirm:$false   ??

Activity

  1. StevenBucher98 commented on Jan 19, 2022

    @StevenBucher98

    Should this always prompt you?

  2. ThomasNieto commented on Jul 4, 2022

    @ThomasNieto
    Contributor

    Steven Bucher (@StevenBucher98) No, it should not.

    Please do not add additional hurdles when using wildcards. These kinds of extra barriers is what made PowerShellGet v2 so difficult to use since it basically forces people to add -Force or -Confirm:$false to $PSDefaultParameterValues. PowerShell should just do whats its told. Its the user responsibility to make sure they're not doing something dumb. The level of destructiveness is fairly small in the grand scheme of things. In worst case if I uninstall all my modules I can just as easily reinstall. PowerShell has sufficient safeguards with -WhatIf and -Confirm if the user is concerned what the command will do when ran and can compare to the expected result.

    If you need further convincing lets take a look at Remove-Item. I can pass it wildcards or at worst delete all files and folders without any additional prompts and that can be way more destructive than removing a module.

    rm * -Recurse
  3. no-identd commented on Mar 14, 2023

    @no-identd

    Thomas Nieto (@ThomasNieto)

    "If you need further convincing lets take a look at Remove-Item . I can pass it wildcards or at worst delete all files and folders without any additional prompts and that can be way more destructive than removing a module."

    That seems like a terrible argument entirely ignorant of the deep history behind --no-preserve-root on *IX/Linux systems. If anything, Remove-Item should receive augmentation(s) in that regard…

    Also for -WhatIf and -Confirm to actually work, one has to implement a ShouldProcess code block ANYWAY.

    Maybe you meant to voice a preference for the (future) value(s) of ConfirmImpact (i.e. High/Medium/Low) here?

    Also while I totally get your anger, it seems a bit… ignorant of the many things which can drive people to add those to $PSDefaultParameterValues (also, let's not forget about $ConfirmPreference )

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

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions