File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
reference/docs-conceptual/PSScriptAnalyzer/Rules Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 11---
22description : Use ShouldProcess For State Changing Functions
3- ms.date : 06/28/2023
3+ ms.date : 12/05/2024
44ms.topic : reference
55title : UseShouldProcessForStateChangingFunctions
66---
@@ -10,7 +10,12 @@ title: UseShouldProcessForStateChangingFunctions
1010
1111## Description
1212
13- Functions whose verbs change system state should support ` ShouldProcess ` .
13+ Functions whose verbs change system state should support ` ShouldProcess ` . To enable the
14+ ` ShouldProcess ` feature, set the ` SupportsShouldProcess ` argument in the ` CmdletBinding ` attribute.
15+ The ` SupportsShouldProcess ` argument adds ** Confirm** and ** WhatIf** parameters to the function. The
16+ ** Confirm** parameter prompts the user before it runs the command on each object in the pipeline.
17+ The ** WhatIf** parameter lists the changes that the command would make, instead of running the
18+ command.
1419
1520Verbs that should support ` ShouldProcess ` :
1621
@@ -58,3 +63,16 @@ function Set-ServiceObject
5863 ...
5964}
6065```
66+
67+ ## More information
68+
69+ - [ about_Functions_CmdletBindingAttribute] [ 01 ]
70+ - [ Everything you wanted to know about ShouldProcess] [ 04 ]
71+ - [ Required Development Guidelines] [ 03 ]
72+ - [ Requesting Confirmation from Cmdlets] [ 02 ]
73+
74+ <!-- link references -->
75+ [ 01 ] : /powershell/module/microsoft.powershell.core/about/about_functions_cmdletbindingattribute
76+ [ 02 ] : /powershell/scripting/developer/cmdlet/requesting-confirmation-from-cmdlets
77+ [ 03 ] : /powershell/scripting/developer/cmdlet/required-development-guidelines#support-confirmation-requests-rd04
78+ [ 04 ] : /powershell/scripting/learn/deep-dives/everything-about-shouldprocess
You can’t perform that action at this time.
0 commit comments