Introduce new preference variable '$ForcePreference' similar to '$ConfirmPreference'
See original GitHub issueSummary of the new feature/enhancement
In a nutshell, there is no way to generally -Force
all cmdlets to suppress prompts.
This requires to add -Force
to every cmdlet:
My-CmdletWithConfirmation –Force
While for -Confirm
someone could set the $ConfirmPreference
, there is no such variable for -Force
. See also
use -confirm instead of “-force” and Everything you wanted to know about ShouldProcess.
Proposed technical implementation details (optional)
Introduce a preference variable $ForcePreference
similar to $ConfirmPreference.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
about Preference Variables - PowerShell
The preference variables affect the PowerShell operating environment and all commands run in the environment.
Read more >ConfirmPreference - PowerShell Team
Stop-Process is defined as “MEDIUM”. You can then set the variable: $ConfirmPreference to be the level that you want Automatic confirmation ...
Read more >Powershell Preference Variables
The $PSDefaultParameterValues preference variable lets you specify custom default values for just one specific cmdlet or advanced function, see Help about_ ...
Read more >PowerShell: the preference variable $confirmPreference
Now, if the value of the preference variable $confirmPreference is lower than that of a command, the command requires the user to confirm...
Read more >c# - How do I set $ConfirmPreference = "None" for a ...
While the accepted answer solved this specific problem, the correct way of setting $ConfirmImpact preference variable is via session state:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @mklement0 - very helpful! 🥇
Glad to hear it, @fawohlsc. Don’t know if it’s required in your case, but I forgot to mention that you should run
$PSDefaultParameterValues = $PSDefaultParameterValues.Clone()
first, to create a local copy of the dictionary; without that,$PSDefaultParameterValues['*:Force']
- even when run in a non-global scope - takes effect globally. I’ve updated my previous comment accordingly.