Skip to content

Not all aliases have full properties in a new session #11294

@ChrisLGardner

Description

@ChrisLGardner

Steps to reproduce

In a new session with -NoProfile specified (so that no commands have run previously)

Get-Alias gci | Format-List *

I found this while working on #10784 following a comment from @adityapatwardhan. I had to dig down to the SessionStateAliasApis.cs file and put a breakpoint on line 50 to see the state of _currentScope

It doesn't appear to be all aliases, gcm and a bunch of others were fine.

Expected behavior

This works fine as long as you've run at least one command first (that isn't this one or others that interact with the aliases)

HelpUri             : https://go.microsoft.com/fwlink/?LinkID=113308
ResolvedCommandName : Get-ChildItem
DisplayName         : gci -> Get-ChildItem
ReferencedCommand   : Get-ChildItem
ResolvedCommand     : Get-ChildItem
Definition          : Get-ChildItem
Options             : ReadOnly
Description         :
OutputType          : {System.IO.FileInfo, System.IO.DirectoryInfo}
Name                : gci
CommandType         : Alias
Source              :
Version             :
Visibility          : Public
ModuleName          :
Module              :
RemotingCapability  : PowerShell
Parameters          : {[Path, System.Management.Automation.ParameterMetadata], [LiteralPath,
                      System.Management.Automation.ParameterMetadata], [Filter,
                      System.Management.Automation.ParameterMetadata], [Include,
                      System.Management.Automation.ParameterMetadata]…}
ParameterSets       :

Actual behavior

HelpUri             :
ResolvedCommandName :
DisplayName         : gci -> Get-ChildItem
ReferencedCommand   :
ResolvedCommand     :
Definition          : Get-ChildItem
Options             : ReadOnly
Description         :
OutputType          :
Name                : gci
CommandType         : Alias
Source              :
Version             :
Visibility          : Public
ModuleName          :
Module              :
RemotingCapability  : PowerShell
Parameters          :
ParameterSets       :

Environment data

I've checked this in preview 5, 6 and master.

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.4
PSEdition                      Core
GitCommitId                    7.0.0-preview.4-211-gbcc565603cee552b10244be82a2797da2ff38cab
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions