New-ConsoleField
Creates a form field for New-ConsoleForm.
Syntax
New-ConsoleField [-ArgumentList <Object[]>] [-Choices <Object[]>] [-CommandPlaceholder <String>] [-Default <Object>] [-DependsOn <String[]>] [-Describe <Object>] [-Display <Object>] [-Extension <String[]>] [-GroupBy <Object>] [-Height <Int32>] [-Help <String>] [-Integer] [-Kind <Any|File|Folder>] [[-Label] <String>] [-LoadChoices <ScriptBlock>] [-Maximum <Decimal>] [-MaxLength <Int32>] [-MaxLines <Int32>] [-Minimum <Decimal>] [-MinLength <Int32>] [-MustExist] [-Name] <String> [-NoRemember] [-OffText <String>] [-OnText <String>] [-Page <String>] [-Parameter <String>] [-Pattern <String>] [-PatternMessage <String>] [-Placeholder <String>] [-Preview <ScriptBlock>] [-Required] [-Step <Decimal>] [-Type <ConsoleFieldType>] [-Validate <ScriptBlock>] [-VisibleWhen <ScriptBlock>] [<CommonParameters>]#All Parameter SetsDescription
Creates a form field for New-ConsoleForm.
A field has a name (its key in the result), a label, help shown while it has focus, a default, validation (-Required, -Validate and the type's own checks) and the command-line parameter it supplies (-Parameter) for the equivalent command. -VisibleWhen shows it only while a condition on the other values holds ($Values). -DependsOn resets it when those fields change; with -LoadChoices its options are loaded again in their own runspace (a spinner shows, Esc cancels), from the current values ($Values).
Examples
EXAMPLE 1
New-ConsoleField -Name 'Name'Parameters
- -ArgumentList Object[]
- More arguments for the -LoadChoices script.
- -Choices Object[]
- The choices of a Select or MultiSelect field (any objects).
- -CommandPlaceholder String
- What stands in for a secret in the equivalent command.
- -Default Object
- The default (for choices: the choice object or its text; for multi-selections: several).
- -DependsOn String[]
- Fields whose change resets this one (and reloads its choices).
- -Describe Object
- A sentence for the focused choice: a property name or a scriptblock.
- -Display Object
- What to show for a choice: a property name or a scriptblock.
- -Extension String[]
- File extensions offered as path suggestions.
- -GroupBy Object
- The group of a choice: a property name or a scriptblock.
- -Height Int32
- The visible rows of the text area dialog (TextArea, default 8).
- -Help String
- Help shown while the field has focus.
- -Integer SwitchParameter
- Whole numbers only.
- -Kind PathKind
- What a path field accepts: Any, File or Folder.
- Possible values:
Any,File,Folder - -Label String
- The label (default: the name).
- -LoadChoices ScriptBlock
- Loads the choices in their own runspace; the script gets the current values as $Values (and its first argument).
- -Maximum Decimal
- The largest number, or the most choices of a MultiSelect field.
- -MaxLength Int32
- The most characters (TextArea).
- -MaxLines Int32
- The most lines (TextArea).
- -Minimum Decimal
- The smallest number, or the fewest choices of a MultiSelect field.
- -MinLength Int32
- The fewest characters of a text or secret field.
- -MustExist SwitchParameter
- Requires a path to exist.
- -Name String
- The key of the value in the result.
- -NoRemember SwitchParameter
- Keeps the value out of presets and remembered choices.
- -OffText String
- Text after a toggle that is off (default No).
- -OnText String
- Text after a toggle that is on (default Yes).
- -Page String
- The wizard page the field is on.
- -Parameter String
- The parameter the field supplies in the equivalent command (Name, -Name or --name).
- -Pattern String
- A pattern a text field must match.
- -PatternMessage String
- The message when -Pattern does not match.
- -Placeholder String
- Muted text while a text field is empty.
- -Preview ScriptBlock
- Preview content for the focused choice in the editor ($_ is the choice).
- -Required SwitchParameter
- Refuses an empty value.
- -Step Decimal
- The step of a number field.
- -Type ConsoleFieldType
- The kind: Text (default), Secret, Number, Toggle, Select, MultiSelect or Path.
- Possible values:
Text,Secret,Number,Toggle,Select,MultiSelect,Path,TextArea - -Validate ScriptBlock
- A validator: $_ is the value, $Values the other values; return $true (or nothing), $false or an error message.
- -VisibleWhen ScriptBlock
- Shows the field only while this returns $true ($Values holds the other 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.