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

> Avoid reserved words as function names

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

| Property | Value            |
| -------- | ---------------- |
| Severity | Warning          |
| Category | PSScriptAnalyzer |
| Auto-fix | No               |

## Description

Avoid using reserved words as function names. Using reserved words as function names can cause
errors or unexpected behavior in scripts.

## How to Fix

Avoid using any of the reserved words as function names. Choose a different name that's not a
reserved word.

See [about\_Reserved\_Words][01] for a list of reserved words in PowerShell.

## Examples

### Problematic code

```powershell theme={null}
# Function is a reserved word
function function {
    Write-Host "Hello, World!"
}
```

### Correct code

```powershell theme={null}
# myFunction is not a reserved word
function myFunction {
    Write-Host "Hello, World!"
}
```

[01]: /powershell/module/microsoft.powershell.core/about/about_reserved_words

## Source

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