Set-ConsoleFormValue
Sets field values of a form, whether or not it is shown.
Syntax
Set-ConsoleFormValue [-Form] <Form> [-Value] <Object> [<CommonParameters>]#All Parameter SetsDescription
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
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 $formStart a form from the answers of its last run
Parameters
- -Form Form
- The form from New-ConsoleForm.
- -Value Object
- 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.