Skip to content

Commit 8c7a936

Browse files
committed
Describe the purpose of ShouldProcess
1 parent 012b25c commit 8c7a936

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

reference/docs-conceptual/PSScriptAnalyzer/Rules/UseShouldProcessForStateChangingFunctions.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Use ShouldProcess For State Changing Functions
3-
ms.date: 06/28/2023
3+
ms.date: 12/05/2024
44
ms.topic: reference
55
title: 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

1520
Verbs 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

0 commit comments

Comments
 (0)