Skip to content
ConsoleMonster
Cmdlet

New-ConsoleKeyValueItem

Module ConsoleMonster
Inputs
None
Outputs
ConsoleMonster.Widgets.KeyValueItem

Creates one key/value pair, with an optional status or presenter, for New-ConsoleKeyValue.

Syntax

New-ConsoleKeyValueItem [-Key] <String> [-Markup] [-Presenter <String>] [-Status <StatusKind>] [-Unit <String>] [[-Value] <Object>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Creates one key/value pair, with an optional status or presenter, for New-ConsoleKeyValue.

Use it inside the script block of New-ConsoleKeyValue or Write-ConsoleKeyValue when a pair needs more than a hashtable gives: a status marker before the value (-Status), markup in the value (-Markup), or a value formatted by a presenter (-Presenter Bytes, Duration, Date...). Values are shown literally unless -Markup is used. To add pairs to a list made earlier, pipe the list to Add-ConsoleItem.

Examples

Authored help example

EXAMPLE 1

New-ConsoleKeyValue {
    New-ConsoleKeyValueItem 'Module' '[bold]ConsoleMonster[/]' -Markup
    New-ConsoleKeyValueItem 'Signing' 'skipped' -Status Skip
    New-ConsoleKeyValueItem 'Tests' '1 skipped on PowerShell 7' -Status Warn
} | Write-ConsoleWidget

Facts with status marks

EXAMPLE 2

New-ConsoleKeyValue {
    New-ConsoleKeyValueItem 'Package size' 1482113 -Presenter Bytes
    New-ConsoleKeyValueItem 'Built in' (New-TimeSpan -Seconds 48) -Presenter Duration
} | Write-ConsoleWidget

Values formatted by presenters

Parameters

-Key String requiredposition: 0
The key (plain text).
-Markup SwitchParameter optional
Treat the value as markup.
-Presenter String optional
How the value is shown: Bytes, Duration, Date, Number, Boolean, Status, Progress, DataBar, Link, Markup or Text.
-Status StatusKind optional
A status marker before the value: 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 the Number presenter, for example ms.
-Value Object optionalposition: 1
The value. Shown literally unless -Markup is used; with -Presenter it keeps its type and is formatted by that presenter.

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.