Skip to content
ConsoleMonster
Cmdlet

New-ConsoleMenuRunResult

Module
ConsoleMonster
Inputs
None
Outputs
ConsoleMonster.Interactive.MenuRunResult

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

Syntax

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

Description

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); -ElapsedSeconds overrides it.

Examples

Example 1

New-ConsoleMenuItem 'Back up now' -Action {
    $dashboard = New-ConsoleDashboard -Title 'Backup' -Content { New-ConsoleStatusList -Item 'Scan files', 'Copy changes' }
    $null = $MenuContext.Run($dashboard, {
        Update-ConsoleStatusItem -Key 'Scan files' -Status Pass
        Update-ConsoleStatusItem -Key 'Copy changes' -Status Pass
        New-ConsoleMenuRunResult '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-ConsoleMenuRunResult '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).
-ElapsedSeconds Double optional
Elapsed seconds shown with the result and kept in history; defaults to the run session clock. Fractional seconds are accepted.
-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.