Skip to content
ConsoleMonster
Cmdlet

New-ConsoleTreeNode

Module ConsoleMonster
Inputs
None
Outputs
ConsoleMonster.Widgets.TreeNode

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>]
#
Parameter set: All Parameter Sets

Description

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

Authored help example

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-ConsoleWidget

A 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-ConsoleWidget

Leaves 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-ConsoleWidget

A value shown through a presenter

Parameters

-Content ScriptBlock optionalposition: 1
A script block that emits the child nodes: New-ConsoleTreeNode calls, or strings for leaves (shown literally).
-Detail Object optional
A muted note after the label, for example a count or a short reason (shown literally).
-Label Object requiredposition: 0
The label (markup allowed; rich text from New-ConsoleText keeps its colours).
-Presenter String optional
How -Value is shown: Bytes, Duration, Date, Number, Boolean, Status, Progress, DataBar, Link, Markup or Text.
-Status StatusKind optional
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 optional
A unit for -Value with the Number presenter, for example ms.
-Value Object optional
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.