Skip to content

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

Closed

Description

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 Aditya Patwardhan (@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

Activity

  1. added
    Issue-Question
    on Dec 8, 2019
  2. iSazonov commented on Dec 9, 2019

    @iSazonov
    Collaborator

    We already discussed this. To have all the properties we have to import modules. It is very expensive.
    Also problem is possible alias conflicts so that we should get aliases only in interactive session and only after importing a module.

  3. added
    Resolution-Answered
    on May 7, 2020
  4. ghost closed this as completedon Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-QuestionResolution-Answered

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions