Register-ConsoleView
Registers how a type is shown by Enable-ConsoleFormatting.
Syntax
Register-ConsoleView
[-Group <String>]
[-GroupBy <Object>]
[-Property <Object[]>]
[-Shaper <ScriptBlock>]
[-Summary <ScriptBlock>]
[-Title <ScriptBlock>]
[-TypeName] <String[]>
[-View <ConsoleViewKind>]
[<CommonParameters>]#RegisterRegister-ConsoleView
[-Path] <String[]>
[<CommonParameters>]#FileDescription
Objects whose type names include -TypeName are shown in the given view when they reach the console. -Property picks the columns as in Show-ConsoleTable (names, calculated properties with Presenter options), -GroupBy groups rows under headings, and types with the same -Group are shown together (files and folders). Unregister-ConsoleView removes a registration. Modules can register their own types when they load, or ship a data-only ModuleName.consoleviews.psd1 file without a dependency on ConsoleMonster. Use -Path to import a view file explicitly.
Examples
Example 1
$viewOptions = @{
TypeName = @('Contoso.Server')
View = 'Table'
Property = @('Name', @{ Name = 'State'; Expression = { $_.State }; Presenter = 'StatusWord' }, 'Uptime')
}
Register-ConsoleView @viewOptionsShow a module's result objects as a table
Example 2
$viewOptions = @{
TypeName = @('Inventory.Server')
View = 'Table'
Property = @('Name', 'State')
}
Register-ConsoleView @viewOptions
$server = [pscustomobject]@{ Name = 'web01'; State = 'Online' }
$server.PSObject.TypeNames.Insert(0, 'Inventory.Server')
$server | Show-ConsoleRegister a table for typed inventory records
Parameters
- -Group String
- A group name: consecutive objects of types in the same group are shown in one view.
- -GroupBy Object
- A property name or script block that groups rows under headings.
- -Property Object[]
- The properties, as in Show-ConsoleTable.
- -Shaper ScriptBlock
- A script block that turns each object of the type into what is shown instead ($_ is the object), for example an ordered dictionary of the fields worth showing. It applies in every command (Show-ConsoleTable, -List, -Tree, Show-Console, Show-ConsoleGrid, Compare-ConsoleObject, Out-ConsoleDefault), also to deserialized objects whose type names match. Given alone (without -View, -Property, -GroupBy, -Title or -Group), only the shaper is registered.
- -Summary ScriptBlock
- A script block that sums up the objects shown together, under the view on the console ($_ and the first argument are all of them). It returns facts: strings, or hashtables with Value, Label (after the value), Caption (before it), Presenter (Bytes, Duration, Sparkline, Progress...) and Role (Pass, Warn, Fail, Muted...). Return nothing when there is nothing worth saying, for example for one or two objects.
- -Title ScriptBlock
- A script block for each object's title ($_ is the object): a shared title heads the view, different titles group the rows.
- -TypeName String[]
- The type names (as in PSObject.TypeNames).
- -View ConsoleViewKind
- The view: Table (default), Cards, Tree, Inspector or Chart.
- Possible values:
Empty,Text,Code,Inspector,Table,Cards,Tree,Chart,Grid,Auto,List,Json,Error,Markdown,Rule - -Path String[]
- Imports a data-only .consoleviews.psd1 file. Modules can ship a same-named file beside their manifest without depending on ConsoleMonster.
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.