Skip to content
ConsoleMonster
Cmdlet

New-ConsoleRunResult

Module ConsoleMonster
Inputs
None
Outputs
ConsoleMonster.Interactive.RunResult

Creates the result a menu run returns: a title, a status, a summary, figures and next actions.

Syntax

New-ConsoleRunResult [-Details <IWidget>] [-Elapsed <TimeSpan>] [-Figure <IDictionary>] [-FigureStatus <IDictionary>] [-Next <IDictionary>] [-Status <StatusKind>] [-Summary <String>] [-Title] <String> [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Creates the result a menu run returns: a title, a status, a summary, figures and next actions.

Return it from the script block of $MenuContext.Run (a live dashboard started from a menu action): when the run ends, the menu shows it as a result screen with the figures as large values and the next actions as items. -Figure maps labels to values (use [ordered] to keep order); -Next maps action titles to script blocks, which run with $MenuContext like any menu action. -FigureStatus colours the figures that need attention (Pass, Warn, Fail by label). -Status takes the shared status vocabulary (default Pass). The time shown with the result is the run's time on its session clock (real time, or a simulated clock given to the run); -Elapsed overrides it.

Examples

Authored help example

EXAMPLE 1

New-ConsoleMenuItem 'Back up now' -Action {
    $dashboard = New-ConsoleDashboard -Title 'Backup' { New-ConsoleStatusList -Item 'Scan files', 'Copy changes' }
    $null = $MenuContext.Run($dashboard, {
        Update-ConsoleStatus 'Scan files' -Status Pass
        Update-ConsoleStatus 'Copy changes' -Status Pass
        New-ConsoleRunResult 'Backup finished' -Summary '1 284 files copied, 312 MB.' -Figure ([ordered] @{ files = '1 284'; copied = '312 MB' }) -Next @{
            'Show where the log is' = { $MenuContext.Toast('Log: D:\Backups\backup.log') }
        }
    })
}

A backup run that reports what it did

EXAMPLE 2

New-ConsoleRunResult 'Checks finished' -Status Warn -Figure ([ordered] @{ passed = 41; warnings = 3; failed = 0 }) -FigureStatus @{ passed = 'Pass'; warnings = 'Warn' }

Coloured figures

Parameters

-Details IWidget optional
A widget with details under the figures (for example a table of what changed).
-Elapsed TimeSpan optional
How long the run took, shown with the result and kept in the history (a TimeSpan, seconds, or a number with a unit such as 86s). Default: the time on the run's session clock, which is real time, or the simulated clock's time when the run was given one (New-ConsoleClock).
-Figure IDictionary optional
Figures: labels mapped to values, shown large (use [ordered] to keep order).
-FigureStatus IDictionary optional
The status of figures that need attention, by label: their numbers take the status colour (Pass, Warn, Fail...). Figures not named stay neutral.
-Next IDictionary optional
Next actions: titles mapped to script blocks, run with $MenuContext like menu actions.
-Status StatusKind optional
The outcome (default Pass): Pass, Fail, Warn or Skip, or PowerShell's words such as Success and Error.
Possible values: Pending, Running, Pass, Fail, Warn, Skip, Info
-Summary String optional
One or two sentences under the title.
-Title String requiredposition: 0
The result title.

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.