Skip to main content
powershell/PSAvoidShouldContinueWithoutForce 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/PSAvoidShouldContinueWithoutForce"] or by setting rules.powershell.PSAvoidShouldContinueWithoutForce.severity = "warning" in .tally.toml.

Description

Functions that use ShouldContinue should have a boolean force parameter to allow user to bypass it. You can get more details by running Get-Help about_Functions_CmdletBindingAttribute and Get-Help about_Functions_Advanced_Methods command in PowerShell.

How

Call the ShouldContinue method in advanced functions when ShouldProcess method returns $true.

Examples

Problematic code

Correct code

Source

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