Why Powershell Format-List * Does Not List All Properties

When I do ... | Format-List, one of the properties is Path.
When I do ... | Format-List *, the property is Pathmissing.
Why?

[DBG]: PS C:\Directory>> $MyInvocation.MyCommand | Format-List

Name        : 
CommandType : Script
Definition  : $MyInvocation.MyCommand | Format-List
Path        : 

[DBG]: PS C:\Directory>> $MyInvocation.MyCommand | Format-List *

HelpUri            : 
ScriptBlock        : $MyInvocation.MyCommand | Format-List *
Definition         : $MyInvocation.MyCommand | Format-List *
OutputType         : {}
Name               : 
CommandType        : Script
Visibility         : Public
ModuleName         : 
Module             : 
RemotingCapability : PowerShell
Parameters         : 
ParameterSets      : {}
+4
source share
2 answers

To compliment gms0ulman's answer ...

PowerShell displays objects in the console based on format.ps1xml files. From File Formatting Overview

, (, ), ( format.ps1xml). Windows PowerShell , Windows PowerShell...

PowerShell, , , . PowerShellCore.format.ps1xml. $MyInvocation.MyCommand , System.Management.Automation.ScriptInfo. , .

<View>
    <Name>System.Management.Automation.ScriptInfo</Name>
    <ViewSelectedBy>
        <TypeName>System.Management.Automation.ScriptInfo</TypeName>
    </ViewSelectedBy>


    <ListControl>
        <ListEntries>
            <ListEntry>
               <ListItems>
                    <ListItem>
                        <PropertyName>Name</PropertyName>
                    </ListItem>
                    <ListItem>
                        <PropertyName>CommandType</PropertyName>
                    </ListItem>
                    <ListItem>
                        <PropertyName>Definition</PropertyName>
                    </ListItem>
                    <ListItem>
                        <PropertyName>Path</PropertyName>
                    </ListItem>
                </ListItems>
            </ListEntry>
        </ListEntries>
    </ListControl>
</View>

, , Name, CommandType, Definition Path. , * 1

, , , - , .

1 , *. -Force, . , .

+4

Path . Format-List - * - . , , , - , .
. Matt

, $MyInvocation.MyCommand | Get-Member , Path . , , script.

script $MyInvocation.MyCommand | Format-List $MyInvocation.MyCommand | Format-List * Path


$MyInvocation , script.

about_Automatic_Variables. , PowerShell script, $MyInvocation () .

+3

Source: https://habr.com/ru/post/1689246/


All Articles