Skip to content

Extend PSAvoidUsingCmdletAliases rule to also warn about implicitly aliased cmdlets via automatic Get- discovery #926

Closed
@bergmeister

Description

@bergmeister

Steps to reproduce

PowerShell has this undocumented feature that if it cannot find/resolve a command, it will try to append Get- to the command as a last resort of finding it. As far as I am aware, this works on every version of PowerShell but using it in a script should maybe be discouraged because

  • It could make maintenance hard, should this undocumented feature get broken, therefore a script should not rely on it
  • It could make the script difficult to read for many people
Invoke-ScriptAnalyzer -ScriptDefinition 'Verb' # Executing 'Verb' will execute 'Get-Verb'

Expected behavior

A warning should be given, the most appropriate one is probably PSAvoidUsingCmdletAliases since having a rule of its own is not worth the expense (computational, maintenance and for people managing their rule set)

Actual behavior

No warning

Environment data

Latest development version of 16.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions