> ## 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/PSAvoidGlobalFunctions

> Avoid global functions and aliases

`powershell/PSAvoidGlobalFunctions` is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.

| Property | Value             |
| -------- | ----------------- |
| Severity | Warning           |
| Category | PSScriptAnalyzer  |
| Default  | Disabled in tally |
| Auto-fix | No                |

<Note>
  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`.
</Note>

## 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

```powershell theme={null}
function global:functionName {}
```

### Correct code

```powershell theme={null}
function functionName {}
```

## Source

This rule documentation is adapted from Microsoft's PSScriptAnalyzer documentation for
[AvoidGlobalFunctions](https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalFunctions.md),
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
