Documentation Index
Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
Use this file to discover all available pages before exploring further.
powershell/PSUseShouldProcessForStateChangingFunctions is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in
Dockerfiles.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | PSScriptAnalyzer |
| Auto-fix | No |
Description
Functions whose verbs change system state should supportShouldProcess. To enable the
ShouldProcess feature, set the SupportsShouldProcess argument in the CmdletBinding attribute.
The SupportsShouldProcess argument adds Confirm and WhatIf parameters to the function. The
Confirm parameter prompts the user before it runs the command on each object in the pipeline.
The WhatIf parameter lists the changes that the command would make, instead of running the
command.
Verbs that should support ShouldProcess:
NewSetRemoveStartStopRestartResetUpdate
How
Include theSupportsShouldProcess argument in the CmdletBinding attribute.
Examples
Problematic code
Correct code
More information
- about_Functions_CmdletBindingAttribute
- Everything you wanted to know about ShouldProcess
- Required Development Guidelines
- Requesting Confirmation from Cmdlets