New-ConsoleTable
Creates a console table from pipeline objects.
Syntax
New-ConsoleTable
[-Border <Rounded| Square| Double| Minimal| Rule>]
[-Caption <Object>]
[-CardsBelow <Int32>]
[-Expand]
[-GroupBy <Object>]
[[-InputObject] <PSObject[]>]
[-MaxRows <Int32>]
[-NoHeaderSeparator]
[-NoSort]
[-Property <Object[]>]
[-ShowGroupColumn]
[-ShowTotals]
[-StatusProperty <String>]
[-Title <Object>]
[-Wrap]
[<CommonParameters>]#ObjectsNew-ConsoleTable
[-Border <Rounded| Square| Double| Minimal| Rule>]
[-Caption <Object>]
[-CardsBelow <Int32>]
[-Descending]
[-Expand]
[-Filter <String>]
[-GroupBy <Object>]
[[-InputObject] <PSObject[]>]
[-KeyProperty <String>]
-Live
[-MaxRows <Int32>]
[-NoHeaderSeparator]
[-NoSort]
[-Property <Object[]>]
[-ShowGroupColumn]
[-ShowTotals]
[-SortColumn <Object>]
[-StatusProperty <String>]
[-Table <Table>]
[-Title <Object>]
[[-WidgetId] <String>]
[-Wrap]
[<CommonParameters>]#LiveNew-ConsoleTable
-Bind <ScriptBlock>
[-Border <Rounded| Square| Double| Minimal| Rule>]
[-Caption <Object>]
[-CardsBelow <Int32>]
[-Expand]
[-GroupBy <Object>]
[-MaxRows <Int32>]
[-NoHeaderSeparator]
[-NoSort]
[-Property <Object[]>]
[-ShowGroupColumn]
[-ShowTotals]
[-StatusProperty <String>]
[-Title <Object>]
[-Wrap]
[<CommonParameters>]#BindDescription
Columns come from -Property or from the first object's properties (or hashtable keys). Property descriptors accept presenter names or configured C# ICellPresenter instances. Columns size to their content, numbers are right-aligned, long values wrap. A -StatusProperty column shows status markers (pass, fail, warn...) as the row's one colour signal.
Examples
Example 1
$tableOptions = @{
Property = @('Name', 'Status', 'Region')
StatusProperty = 'Status'
Title = 'Servers'
}
@(
[pscustomobject]@{ Name = 'web01'; Status = 'Pass'; Region = 'East' }
[pscustomobject]@{ Name = 'web02'; Status = 'Warn'; Region = 'West' }
) | New-ConsoleTable @tableOptions | Show-ConsoleBuild a table widget from two server records and display it. Property orders the columns. StatusProperty maps the values in Status to markers. A dashboard or layout can consume the same widget in its Content block.
Example 2
$items = @(
[pscustomobject]@{ Name = 'web01'; Status = 'Pass' }
[pscustomobject]@{ Name = 'web02'; Status = 'Warn' }
)
Show-ConsoleApp -Content {
New-ConsoleTextInput -Key Query
$tableOptions = @{
Bind = { $items | Where-Object Name -Like "*$($State.Query)*" }
Property = @('Name', 'Status')
StatusProperty = 'Status'
}
New-ConsoleTable @tableOptions
}Filter rows as the app's Query field changes. New-ConsoleTextInput writes to the state key named Query. The Bind script block reads that key from the current $State hashtable and emits matching records, which the table turns into rows. Start with an empty query to see both rows, then type web02.
Example 3
Get-ConsoleDemo -Slug 'server-estate' | Select-Object -ExpandProperty Source
Get-ConsoleDemo -Slug 'live-filter' | Select-Object -ExpandProperty SourceRead any of these gallery scripts to see New-ConsoleTable in a complete example. Each lookup returns the script's source. Use the same slug with Show-ConsoleDemo to run it.
Parameters
- -Border TableBorder
- Border: Rounded, Square, Double, Minimal or None.
- Possible values:
Rounded,Square,Double,Minimal,Rule - -Caption Object
- A muted caption below the table.
- -CardsBelow Int32
- Uses cards below this width; zero keeps a grid.
- -Expand SwitchParameter
- Fill the available width. The text columns share the spare width in proportion to their widths, while number, date and status columns keep their natural width; a column hashtable's Weight (or Flexible) decides the share instead, and Width or MaxWidth holds.
- -GroupBy Object
- Groups rows by a property or script block.
- -InputObject PSObject[]
- The objects to show, one row each.
- -MaxRows Int32
- For Live, keeps this many recent rows; zero keeps all.
- -NoHeaderSeparator SwitchParameter
- Underline the header instead of drawing a separator row under it.
- -NoSort SwitchParameter
- Keeps groups in input order.
- -Property Object[]
- Properties to show, in order.
- -ShowGroupColumn SwitchParameter
- Keeps the grouping property in the table columns.
- -ShowTotals SwitchParameter
- Adds totals for numeric columns.
- -StatusProperty String
- A property whose values are statuses (pass/fail/warn/skip/running).
- -Title Object
- A title above the table.
- -Wrap SwitchParameter
- Wraps long cell values without limiting their line count.
- -Descending SwitchParameter
- For Live, sorts larger values first.
- -Filter String
- Only displays rows whose cell values match every literal word before formatting, ignoring case. The live table retains hidden rows.
- -KeyProperty String
- For Live, the input property used as the stable row key; omitted uses the first column.
- -Live SwitchParameter
- Creates a keyed live table using the same column and row configuration.
- -SortColumn Object
- For Live, the column index or header used for sorting.
- -Table Table
- For Live, a table model supplying columns and presentation options.
- -WidgetId String
- The live widget identifier; default table.
- -Bind ScriptBlock
- Application-dependent object producer. Receives param($State) and injected $State as a native hashtable on the owning input thread. Emit objects, not widgets; columns and formatting use the same builder as ordinary tables.
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.