New-ConsoleRegion
Creates a named region whose content can be replaced while a dashboard runs.
Syntax
New-ConsoleRegion
[[-Content] <Object>]
[-Fill]
[-Height <Int32>]
[-Horizontal <Left| Center| Right>]
[-Padding <Int32[]>]
[-Vertical <Top| Middle| Bottom>]
[-Weight <Double>]
[[-WidgetId] <String>]
[<CommonParameters>]#All Parameter SetsDescription
Put the region anywhere in a layout (inside New-ConsolePanel keeps the frame), then call Update-Console -WidgetId with a new widget from the dashboard script. The swap is queued like every update, lands between frames and redraws only what changed.
Examples
Example 1
$panelOptions = @{
Title = 'Result'
Content = {
$regionOptions = @{
WidgetId = 'main'
Content = {
$progressOptions = @{
Indeterminate = $true
Label = 'Querying'
WidgetId = 'spinner'
}
New-ConsoleProgress @progressOptions
}
}
New-ConsoleRegion @regionOptions
}
}
New-ConsolePanel @panelOptionsBuild a panel with an indeterminate spinner as its initial content. WidgetId main identifies the region for a later Update-Console -Content call. WidgetId spinner identifies the progress widget currently inside it.
Example 2
$regionOptions = @{
Horizontal = 'Center'
Padding = @(1)
Content = {
$textOptions = @{
Text = @('Ready')
}
New-ConsoleText @textOptions
}
}
New-ConsoleRegion @regionOptions | Show-ConsoleCenter Ready and leave one cell of padding on each side. Padding is an integer array. The one-entry form uses that entry for all four sides. With two entries the order is horizontal then vertical. With four entries it is left, top, right, bottom.
Example 3
Get-ConsoleDemo -Slug 'build-steps' | Select-Object -ExpandProperty Source
Get-ConsoleDemo -Slug 'log-tail' | Select-Object -ExpandProperty SourceRead any of these gallery scripts to see New-ConsoleRegion in a complete example. Each lookup returns the script's source. Use the same slug with Show-ConsoleDemo to run it.
Parameters
- -Content Object
- A script block whose widgets are the first content.
- -Fill SwitchParameter
- Takes the remaining height.
- -Height Int32
- A fixed height in rows.
- -Horizontal HorizontalAlignment
- Horizontal placement within the available space.
- Possible values:
Left,Center,Right - -Padding Int32[]
- Padding as one value for all sides, two for horizontal and vertical, or four for left, top, right and bottom.
- -Vertical VerticalAlignment
- Vertical placement within the available space.
- Possible values:
Top,Middle,Bottom - -Weight Double
- The share of the remaining space in a row or column layout.
- -WidgetId String
- The region name used by Update-Console.
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.