New-ConsoleTreeNode
Creates a tree node with an optional status, a muted detail and child nodes, for New-ConsoleTree.
Syntax
New-ConsoleTreeNode [[-Content] <ScriptBlock>] [-Detail <Object>] [-Label] <Object> [-Presenter <String>] [-Status <StatusKind>] [-Unit <String>] [-Value <Object>] [<CommonParameters>]#All Parameter SetsDescription
Creates a tree node with an optional status, a muted detail and child nodes, for New-ConsoleTree.
Use it inside the script block of New-ConsoleTree, or inside another New-ConsoleTreeNode to nest. The label accepts markup or rich text from New-ConsoleText. -Status shows a status marker before the label (Pass, Fail, Warn, Skip, Info, Running, Pending, or PowerShell's words such as Success, Warning and Error). -Detail is a muted note after the label, and -Value a value formatted by a presenter (sizes, dates, durations). The script block emits the children: more New-ConsoleTreeNode calls, or strings for leaves (shown literally). To add nodes to a tree made earlier, pipe the tree to Add-ConsoleItem.
Examples
EXAMPLE 1
New-ConsoleTree '[bold]evotec.xyz[/]' {
New-ConsoleTreeNode 'MX' -Status Pass -Detail '2 records' {
New-ConsoleTreeNode 'evotec-xyz.mail.protection.outlook.com' -Detail 'priority 0'
}
New-ConsoleTreeNode 'DMARC' -Status Fail -Detail 'p=none'
} | Write-ConsoleWidgetA mail domain with records and their state
EXAMPLE 2
New-ConsoleTree 'Domain controllers' {
New-ConsoleTreeNode 'ad.adatum.com' { 'DC01', 'DC02' }
New-ConsoleTreeNode 'eu.ad.adatum.com' -Status Warn -Detail 'one offline' { 'DC07' }
} | Write-ConsoleWidgetLeaves from a list of names
EXAMPLE 3
New-ConsoleTree 'Reports share' {
New-ConsoleTreeNode 'Weekly' -Value 734003200 -Presenter Bytes
New-ConsoleTreeNode 'Archive' -Value 9663676416 -Presenter Bytes -Status Warn
} | Write-ConsoleWidgetA value shown through a presenter
Parameters
- -Content ScriptBlock
- A script block that emits the child nodes: New-ConsoleTreeNode calls, or strings for leaves (shown literally).
- -Detail Object
- A muted note after the label, for example a count or a short reason (shown literally).
- -Label Object
- The label (markup allowed; rich text from New-ConsoleText keeps its colours).
- -Presenter String
- How -Value is shown: Bytes, Duration, Date, Number, Boolean, Status, Progress, DataBar, Link, Markup or Text.
- -Status StatusKind
- A status marker before the label: Pass, Fail, Warn, Skip, Info, Running or Pending (PowerShell's words such as Success, Warning and Error work too).
- Possible values:
Pending,Running,Pass,Fail,Warn,Skip,Info - -Unit String
- A unit for -Value with the Number presenter, for example ms.
- -Value Object
- A value after the label, formatted by -Presenter or by the presenter its type suggests (dates, sizes, durations, booleans).
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.