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

Description

Globally scoped functions override existing functions within the sessions with matching names. This name collision can cause difficult-to-debug issues for consumers of modules. To understand more about scoping, see Get-Help about_Scopes.

How

Use other scope modifiers for functions.

Examples

Problematic code

Correct code

Source

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