Skip to main content
powershell/PSShouldProcess is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.
tally disables this rule by default for Dockerfile RUN snippets because a RUN executes statements inline rather than defining cmdlets, parameters, or modules with external callers. Re-enable it with include = ["powershell/PSShouldProcess"] or by setting rules.powershell.PSShouldProcess.severity = "warning" in .tally.toml.

Description

If a cmdlet declares the SupportsShouldProcess attribute, then it should also call ShouldProcess. A violation is any function which either declares SupportsShouldProcess attribute but makes no calls to ShouldProcess or it calls ShouldProcess but does not declare SupportsShouldProcess. For more information, see the following articles:

How

To fix a violation of this rule, please call ShouldProcess method when a cmdlet declares SupportsShouldProcess attribute. Or please add SupportsShouldProcess attribute argument when calling ShouldProcess.

Examples

Problematic code

Correct code

Source

This rule documentation is adapted from Microsoft’s PSScriptAnalyzer documentation for ShouldProcess, licensed under CC BY 4.0.