Skip to content

Get-Help does not resolve aliases to scripts if they are not in the path #2899

@nightroman

Description

@nightroman

The original bug is filed here, PowerShell v5.1
I can reproduce it with the latest powershell-6.0.0-alpha.14-win7-x86.

Here is the description of the issue and steps to reproduce.

Create a directory C:\TEMP\HelpAlias (we assume it is not in the path yet).

Create a script Test-Me.ps1 in it:

<#
.Synopsis
    Test help

.Description
    Test help
#>

Open a PowerShell console and invoke the following commands:

    0> Set-Alias zz C:\TEMP\HelpAlias\Test-Me.ps1
    0> Get-Help zz

        Name          : zz
        Category      : Alias
        Synopsis      : Test-Me.ps1
        Component     :
        Role          :
        Functionality :

    0> $env:path = $env:path + ';C:\TEMP\HelpAlias'
    0> Get-Help zz

        NAME
            C:\TEMP\HelpAlias\Test-Me.ps1

        SYNOPSIS
            Test help

        SYNTAX
            C:\TEMP\HelpAlias\Test-Me.ps1 [<CommonParameters>]

        DESCRIPTION
            Test help

Expected behavior

Get-Help works for properly defined aliases to scripts regardless of
their location, i.e. included in the path or not. In other words, the
result is the same as if Get-Help is invoked with the script path
defined by the alias.

Actual behavior

We can see that the alias zz is not resolved by Get-Help when the script is
not the path. Then it is resolved fine after adding the directory to the path
and Get-Help zz gets the expected help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions