Skip to content

Latest commit

 

History

History
29 lines (17 loc) · 699 Bytes

AvoidGlobalFunctions.md

File metadata and controls

29 lines (17 loc) · 699 Bytes

Pattern: Use of global function

Issue: -

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.

Example of incorrect code:

function global:functionName {}

Example of correct code:

function functionName {} 

Further Reading