KEMBAR78
Add -FormatEnumerationLimit parameter to Format-List and Format-Table · Issue #16360 · PowerShell/PowerShell · GitHub
Skip to content

Add -FormatEnumerationLimit parameter to Format-List and Format-Table #16360

@doctordns

Description

@doctordns

Summary of the new feature / enhancement

With PowerShell, you sometimes get objects which have properties that are actually an array of objects. The Threads and Modules Properties on System.Diagnostics.Process object. When Format-List/Format-Table formats these parameters, they only include up to a certain number of occurrences, by default 4. The number of enumerations shown is determined by the automatic variable $FormatEnumerationLimit. So if you want more, you just update that variable, typically in a $Profile.

Here is the current behaviour:

PS> $FormatEnumerationLimit
4
PS> Get-Process | Select-Object -Property Name, Threads -First 4

Name                    Threads
----                    -------
AggregatorHost          {5240}
ApplicationFrameHost    {16968, 2848, 18728}
AppVShNotify            {9164}
Atom.SDK.WindowsService {4064, 4908, 4912, 19144…}

PS> $FormatEnumerationLimit = 1
PS> Get-Process | Select-Object -Property Name, Threads -First 4

Name                    Threads
----                    -------
AggregatorHost          {5240}
ApplicationFrameHost    {16968…}
AppVShNotify            {9164}
Atom.SDK.WindowsService {4064…}

I propose adding a new parameter to both Format-List and Format-Table, -FormatEnumerationLimit which overrdes the value of $FormatEnumerationLimit, but just for this command. Like this:

PS> Get-Process | Select-Object -First 4 | Format-Table Name, Threads -FormatEnumerationLimit 2

Name                    Threads
----                    -------
AggregatorHost          {5240}
ApplicationFrameHost    {16968, 2848…}
AppVShNotify            {9164}
Atom.SDK.WindowsService {4064, 4908…}

Proposed technical implementation details (optional)

  • Update each cmdlet with the extra parameter
  • Change the logic for handling enumeration limit by using the parameter value if it is specified.
  • Retain the default value and default variable handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions