Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 940 Bytes

File metadata and controls

44 lines (32 loc) · 940 Bytes
description ms.date ms.topic title
Avoid reserved words as function names
08/31/2025
reference
AvoidReservedWordsAsFunctionNames

AvoidReservedWordsAsFunctionNames

Severity Level: Warning

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 for a list of reserved words in PowerShell.

Example

Wrong

# Function is a reserved word
function function {
    Write-Host "Hello, World!"
}

Correct

# myFunction is not a reserved word
function myFunction {
    Write-Host "Hello, World!"
}