Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 940 Bytes

File metadata and controls

44 lines (32 loc) · 940 Bytes
description Avoid reserved words as function names
ms.date 08/31/2025
ms.topic reference
title 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!"
}