Show-ConsoleTable
Formats pipeline objects as a width-aware table and writes it to the host.
Syntax
Show-ConsoleTable
[-AsString]
[-AsWidget]
[-Border <Rounded| Square| Double| Minimal>]
[-Caption <Object>]
[-CardsBelow <Int32>]
[-Culture <CultureInfo>]
[-Expand]
[-GroupBy <Object>]
[-InputObject <PSObject>]
[-NoHeaderSeparator]
[-NoSort]
[-PassThru]
[[-Property] <Object[]>]
[-ShowGroupColumn]
[-StatusProperty <String>]
[-Title <Object>]
[-Top <Int32>]
[-Total]
[-Width <Int32>]
[-Wrap]
[<CommonParameters>]#All Parameter SetsDescription
Columns come from -Property (like Format-Table: names, wildcards and calculated properties @{ Name; Expression }), from the type's DefaultDisplayPropertySet, or from the objects' properties. Column options go in the same hashtables: Overflow (Wrap, Truncate, TruncateMiddle, Never), MaxLines, Priority, Key, MinWidth, MaxWidth, Width, Alignment, Presenter (Text, Status, Number, Bytes, Duration, Date, DateRelative, DateBoth, Boolean, Bar, Sparkline, Progress, Link), Unit, Aggregate, Header and tone rules (FailAbove, WarnAbove, FailBelow, WarnBelow, PassAbove, PassBelow, Tone). When the table is too wide, low-priority columns hide with a footer that names them; below -CardsBelow cells the rows become record cards. One object stays a one-row table; -View Record shows objects as labelled fields and -View Cards as cards. Redirected output is plain text without escape codes.
Examples
Example 1
Get-ChildItem -File | Sort-Object Length -Descending | Show-ConsoleTable -Top 10 -Total -Property Name, @{ Name = 'Length'; Presenter = 'Bytes'; Aggregate = 'Sum' }, @{ Name = 'FullName'; Overflow = 'TruncateMiddle'; Priority = 1 }Largest files, sizes as bytes, paths shortened in the middle
Example 2
Get-Service | Show-ConsoleTable -GroupBy Status -Property Name, DisplayName, StartTypeServices grouped by status
Parameters
- -AsString SwitchParameter
- Writes the view as one string of plain text instead of drawing it, to keep it in a variable or a file from any script, function or PowerShell version. Without it, PowerShell 7.2+ captures a view typed at the prompt ($x = ..., > file, Out-File); inside scripts and functions, and on Windows PowerShell 5.1, the view is drawn on the screen. Piped into another command (Out-Host, Out-String, Select-String) the view goes on as plain lines, without colour. Cannot be combined with -PassThru.
- -AsWidget SwitchParameter
- Writes the table widget to the pipeline instead of drawing it (for Export-ConsoleFrame, New-ConsolePanel or a dashboard).
- -Border TableBorder
- Border style: Rounded, Square, Double, Minimal or None.
- Possible values:
Rounded,Square,Double,Minimal - -Caption Object
- A caption below the table (markup, muted).
- -CardsBelow Int32
- Below this width (in cells) rows become record cards when the grid cannot fit; 0 disables cards. Default 60.
- -Culture CultureInfo
- The culture for numbers and dates, for example en-US or pl-PL (labels stay English). Defaults to CONSOLEMONSTER_CULTURE, then the current culture, as PowerShell's own formatting does.
- -Expand SwitchParameter
- Uses the full available width.
- -GroupBy Object
- Groups rows under headings by a property name or a scriptblock; with -Total each group gets a subtotal.
- -InputObject PSObject
- The objects to show (pipeline input).
- -NoHeaderSeparator SwitchParameter
- Underlines the header instead of drawing a separator row.
- -NoSort SwitchParameter
- Keeps the groups of -GroupBy in the order their keys first appear (by default they are sorted by key).
- -PassThru SwitchParameter
- Also writes the input objects to the pipeline.
- -Property Object[]
- Properties (names, wildcards, calculated properties and column option hashtables).
- -ShowGroupColumn SwitchParameter
- Keeps the -GroupBy column in the rows (by default the group heading names the key and the column is left out).
- -StatusProperty String
- A property displayed as a semantic status marker.
- -Title Object
- A title above the table (markup).
- -Top Int32
- Shows only the first N rows followed by "Showing N of M" (totals still cover every row).
- -Total SwitchParameter
- Adds a totals row; numeric columns without an Aggregate option are summed.
- -Width Int32
- Lays the table out for this width instead of the terminal's (for files, logs and previews).
- -Wrap SwitchParameter
- Shows every line of long values. Without it a value wraps onto at most three lines and the last ends with an ellipsis (a column's MaxLines option still applies). Short values (numbers, sizes, booleans, dates, enums, statuses) never wrap either way.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.