Skip to content
ConsoleMonster
Cmdlet

Set-ConsoleFormValue

Module ConsoleMonster
Inputs
System.Object

Sets field values of a form, whether or not it is shown.

Syntax

Set-ConsoleFormValue [-Form] <Form> [-Value] <Object> [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Sets field values of a form, whether or not it is shown.

Each named field takes its value and shows it at once, text and number boxes included; fields not named keep theirs. -Value maps field names (ignoring case) to values: a string, a number, a bool, or a list for a multi-choice field; a value that names a choice (the object, its title or its text) takes that choice. Choice fields whose options load from a field that changed load again, and a value given for such a field is chosen once its options arrive. Unknown names and values a field cannot take are ignored. -Value also takes the result of an earlier run of the form (Read-ConsoleForm -PassThru, or $FormResult in -OnSubmit) to fill in every field again. Call it from a menu action or handler while the menu runs, or before the form is shown.

Examples

Authored help example

EXAMPLE 1

New-ConsoleMenuItem 'Use the lab' -Action { Set-ConsoleFormValue -Form $form -Value @{ Domain = 'lab.example.test'; Parallel = 2 }; $MenuContext.Toast('Lab values applied') }

A menu action that fills in the form opened from another item

EXAMPLE 2

$last = Read-ConsoleForm $form -PassThru
Set-ConsoleFormValue $form $last
Read-ConsoleForm $form

Start a form from the answers of its last run

Parameters

-Form Form requiredposition: 0
The form from New-ConsoleForm.
-Value Object requiredposition: 1pipeline: True (ByValue)
Values by field name (a hashtable), or the result of an earlier run of the form (a form result or its Values).

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.