Home Dashboard Directory Help
Search

Add a variable that allows users to define the default -Confirm response by Kirk Munro


Status: 

Active


5
1
Sign in
to vote
Type: Suggestion
ID: 771096
Opened: 11/14/2012 10:15:56 AM
Access Restriction: Public
0
Workaround(s)
view

Description

Today when you invoke a command with -Confirm, you are prompted to confirm the operation, and the default value (what you get when you press Enter) is "Y", which confirms the operation. There are scenarios where it would make more sense for the default confirmation to be "N", so that commands must be explicitly confirmed. It may also make sense to have no default confirmation, so that users must consciously press "Y" or "N" and hit enter to cause a command to run. Allowing script authors to define this behaviour by changing a new built-in variable value would be a great improvement to PowerShell so that scripts can be written with confirmations that require more thought than simply pressing the Enter key.

Another approach could be to have the -Confirm common parameter accept a hash table, allowing users to define the default value, plus include a custom confirmation message (assuming you had a Message value in the hash table), all as part of a single command call.

In either case, at a minimum PowerShell should allow users to define the default response for confirmation so that they don't have to roll their own confirmation mechanism to get this functionality.
Details
Sign in to post a comment.
Sign in to post a workaround.