New-ConsoleKeyValueItem
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>]#All Parameter SetsDescription
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
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-ConsoleWidgetFacts 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-ConsoleWidgetValues formatted by presenters
Parameters
- -Key String
- The key (plain text).
- -Markup SwitchParameter
- Treat the value as markup.
- -Presenter String
- How the value is shown: Bytes, Duration, Date, Number, Boolean, Status, Progress, DataBar, Link, Markup or Text.
- -Status StatusKind
- 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
- A unit for the Number presenter, for example ms.
- -Value Object
- 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.