Show-Console
Shows objects, text and widgets in a readable view that fits the terminal.
Syntax
Show-Console
[-AsWidget]
[-Border <Rounded| Square| Double| Minimal| Rule>]
[-Caption <Object>]
[-CardsBelow <Int32>]
[-Culture <CultureInfo>]
[-Depth <Int32>]
[-ErrorLayout <Compact| Standard| Detailed>]
[-Exclude <String[]>]
[-Expand]
[-FunctionName <String>]
[-GroupBy <Object>]
[-IncludeHelp]
[-IndentationGuides]
[[-InputObject] <PSObject>]
[-Language <String>]
[-LineNumbers]
[-MaxInner <Int32>]
[-MaxItems <Int32>]
[-MaxNodes <Int32>]
[-MaxRows <Int32>]
[-NoHeaderSeparator]
[-NoPager]
[-NoSort]
[-PassThru]
[-Property <Object[]>]
[-ShowEmpty]
[-ShowGroupColumn]
[-ShowTotals]
[-SourceLines <Int32[]>]
[-StatusProperty <String>]
[-Title <Object>]
[-View <String>]
[-Width <Int32>]
[-Wrap]
[<CommonParameters>]#ObjectsShow-Console
[-AsWidget]
[-Border <Rounded| Square| Double| Minimal| Rule>]
[-Caption <Object>]
[-CardsBelow <Int32>]
[-Culture <CultureInfo>]
[-Depth <Int32>]
[-ErrorLayout <Compact| Standard| Detailed>]
[-Exclude <String[]>]
[-Expand]
[-FunctionName <String>]
[-GroupBy <Object>]
[-IncludeHelp]
[-IndentationGuides]
[-Language <String>]
[-LineNumbers]
[-MaxInner <Int32>]
[-MaxItems <Int32>]
[-MaxNodes <Int32>]
[-MaxRows <Int32>]
[-NoHeaderSeparator]
[-NoPager]
[-NoSort]
[-PassThru]
-Path <String>
[-Property <Object[]>]
[-ShowEmpty]
[-ShowGroupColumn]
[-ShowTotals]
[-SourceLines <Int32[]>]
[-StatusProperty <String>]
[-Title <Object>]
[-View <String>]
[-Width <Int32>]
[-Wrap]
[<CommonParameters>]#PathShow-Console
[-AsWidget]
[-Border <Rounded| Square| Double| Minimal| Rule>]
[-Caption <Object>]
[-CardsBelow <Int32>]
-Content <Object>
[-Culture <CultureInfo>]
[-Depth <Int32>]
[-ErrorLayout <Compact| Standard| Detailed>]
[-Exclude <String[]>]
[-Expand]
[-FunctionName <String>]
[-GroupBy <Object>]
[-IncludeHelp]
[-IndentationGuides]
[-Language <String>]
[-LineNumbers]
[-MaxInner <Int32>]
[-MaxItems <Int32>]
[-MaxNodes <Int32>]
[-MaxRows <Int32>]
[-NoHeaderSeparator]
[-NoPager]
[-NoSort]
[-PassThru]
[-Property <Object[]>]
[-ShowEmpty]
[-ShowGroupColumn]
[-ShowTotals]
[-SourceLines <Int32[]>]
[-StatusProperty <String>]
[-Title <Object>]
[-View <String>]
[-Width <Int32>]
[-Wrap]
[<CommonParameters>]#ContentDescription
Pipe objects to choose a view automatically, or use View for a table, list, object tree, source code, JSON, error or Markdown. Property chooses fields and Width sets the available space. Use New-ConsoleChart, New-ConsoleRule and New-ConsoleTree to construct those widgets.
Markdown document viewer ------------------------
When Markdown with headings exceeds the screen height and goes directly to a rich terminal, the document viewer opens. It shows an outline and lets you fold sections. Press Ctrl+K to jump to a heading, / or Ctrl+F to search, and q to return to PowerShell.
Markdown pager --------------
Long Markdown without headings uses a scrolling pager in the same terminal conditions. Use Up and Down to scroll, PgUp and PgDn to move a page, and Home or End to jump to either end. Press / or Ctrl+F to search. After closing the search bar, use n and Shift+N to move between matches. Press q to return to PowerShell.
Direct output and widget output -------------------------------
Use NoPager to print Markdown directly. Short Markdown and output routed away from the interactive terminal also use direct output. AsWidget returns the view for composition or export. PassThru returns the original objects on the direct rendering path.
Examples
Example 1
Get-Process | Select-Object -First 5 | Show-ConsoleShow a few running processes
Example 2
$showConsoleOptions = @{
View = 'List'
Property = @('ProcessName', 'Id', 'WorkingSet64')
}
Get-Process | Select-Object -First 3 | Show-Console @showConsoleOptionsRead selected fields as a list
Example 3
$showConsoleOptions = @{
View = 'Tree'
Depth = 1
Property = @('Name', 'FullName', 'LastWriteTime')
}
Get-Item . | Show-Console @showConsoleOptionsInspect a file object's members with a bounded tree
Example 4
$showConsoleOptions = @{
LineNumbers = $true
View = 'Code'
Language = 'PowerShell'
Content = {
'Get-Process | Select-Object -First 5'
}
}
Show-Console @showConsoleOptionsShow a PowerShell snippet with line numbers
Example 5
Show-Console -Content {
$panelOptions = @{
Title = 'Build summary'
Content = {
$rowsOptions = @{
Gap = 1
Content = {
$textOptions = @{
Text = @('All checks passed')
Role = 'Pass'
}
New-ConsoleText @textOptions
New-ConsoleRule -Title 'Ready to review'
}
}
New-ConsoleRows @rowsOptions
}
}
New-ConsolePanel @panelOptions
}Compose a panel with native PowerShell script blocks
Example 6
$showConsoleOptions = @{
AsWidget = $true
View = 'List'
Property = @('ProcessName', 'Id')
}
Get-Process | Select-Object -First 3 |
Show-Console @showConsoleOptions |
Export-ConsoleFrame -Format TextReturn a plain-text document for another pipeline command
Example 7
$markdown = @(
'# Plan'
''
1..60 | ForEach-Object { "- Planned check $_" }
''
'# Results'
''
1..60 | ForEach-Object { "- Result $_" }
) -join [Environment]::NewLine
$markdown | Show-Console -View MarkdownOpen a Markdown document with two headings. If it exceeds the terminal height, press Ctrl+K to jump to Results, then press q to return to PowerShell. Use NoPager to print the same document directly.
Example 8
Get-ConsoleDemo -Slug 'welcome-compact' | Select-Object -ExpandProperty Source
Get-ConsoleDemo -Slug 'server-estate' | Select-Object -ExpandProperty SourceRead any of these gallery scripts to see Show-Console in a complete example. Each lookup returns the script's source. Use the same slug with Show-ConsoleDemo to run it.
Parameters
- -AsWidget SwitchParameter
- Returns the constructed widget.
- -Border TableBorder
- Table border style; default Rounded.
- Possible values:
Rounded,Square,Double,Minimal,Rule - -Caption Object
- A table caption.
- -CardsBelow Int32
- Table card breakpoint; default 60 cells.
- -Culture CultureInfo
- The culture used for values.
- -Depth Int32
- Maximum nesting depth; default three.
- -ErrorLayout String
- Error detail: Compact, Standard or Detailed.
- Possible values:
Compact,Standard,Detailed - -Exclude String[]
- Object members omitted without reading their getters.
- -Expand SwitchParameter
- Expands a table to the available width.
- -FunctionName String
- Code view: select the full source lines of one PowerShell function by name without running the script.
- -GroupBy Object
- Groups rows or records by a property or script block.
- -IncludeHelp SwitchParameter
- Include comment-based help immediately before the function selected with FunctionName. Help inside the function is already part of its source.
- -IndentationGuides SwitchParameter
- Show themed scope or indentation guides in a Code view.
- -InputObject PSObject
- The object, widget or text to display.
- -Language String
- Code language; default Auto.
- -LineNumbers SwitchParameter
- Shows code line numbers.
- -MaxInner Int32
- Maximum inner errors; default four.
- -MaxItems Int32
- Maximum inspected items per collection; default 100.
- -MaxNodes Int32
- Maximum hierarchy nodes; default 1000.
- -MaxRows Int32
- Maximum displayed rows or chart groups; zero shows all.
- -NoHeaderSeparator SwitchParameter
- Underlines headers rather than drawing a separator.
- -NoPager SwitchParameter
- Disables default-on Markdown paging.
- -NoSort SwitchParameter
- Preserves the input order of groups.
- -PassThru SwitchParameter
- Returns the original input after display.
- -Property Object[]
- Property names, patterns or calculated column records.
- -ShowEmpty SwitchParameter
- Keeps empty fields in record views.
- -ShowGroupColumn SwitchParameter
- Keeps the grouped property in table rows.
- -ShowTotals SwitchParameter
- Shows a totals row for numeric columns.
- -SourceLines Int32[]
- Code view: the first and last source line to show, inclusive.
- -StatusProperty String
- The property shown through the status presenter.
- -Title Object
- The view title, including markup.
- -View String
- Auto, Table, List, Tree, Code, Json, Error or Markdown. Tree inspects object members; New-ConsoleTree builds node hierarchies.
- Possible values:
Auto,Table,List,Tree,Code,Json,Error,Markdown - -Width Int32
- Layout width; zero resolves the terminal with a 100-cell fallback.
- -Wrap SwitchParameter
- Wraps long table values or code lines.
- -Path String
- A file for Code, Json or Markdown.
- -Content Object
- A widget, text or script block producing display content.
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.