Edit

AvoidGlobalAliases

Severity Level: Warning

Description

This rule detects the use of the New-Alias command to create aliases in the global scope. Global aliases can unintentionally override existing aliases in the session, leading to unexpected behavior and name collisions. Name collisions make it difficult for module consumers to diagnose issues and maintain code reliability.

To avoid this issue, define aliases without the Scope parameter, or use other appropriate scope modifiers. To learn more, see about_Scopes.

Example

Noncompliant

New-Alias -Name Name -Value Value -Scope Global

Compliant

New-Alias -Name Name1 -Value Value