Search notes:

PowerShell: the preference variable $confirmPreference

Each PowerShell command (cmdLets, aliases etc.) is assigned a System.Management.Automation.ConfirmImpact enum-value. The possible values of ConfirmImpact are:
For a given command, such as for example stop-process, the respective value can be determined like so:
PS C:\> $stopProcMeta = new-object System.Management.Automation.CommandMetadata(get-command stop-process)
PS C:\> $stopProcMeta.ConfirmImpact
Medium
Now, if the value of the preference variable $confirmPreference is lower than that of a command, the command requires the user to confirm the required action.
I try to demonstrate that in the following example. By default, the value of $confirmPreference is High:
PS C:\> $confirmPreference
High
Because the value of ConfirmImpact of stop-process is Medium only, I can use stop-process without being asked for confirmation:
PS C:\> start-process notepad
PS C:\> stop-process -name notepad
However, If I set the value of $confirmPreference to Medium, I will be asked to confirm the killing of a process:
PS C:\> start-process notepad
PS C:\> $confirmPreference = 'medium'
PS C:\> stop-process -name notepad

Confirm
Are you sure you want to perform this action?
Performing the operation "Stop-Process" on target "notepad (37468)".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

Links

PowerShell Team: ConfirmPreference

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1758206517, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/language/variable/preference/confirmPreference(70): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78