Skip to content
ConsoleMonster
Cmdlet

Read-ConsoleNumber

Module ConsoleMonster
Inputs
None
Outputs
System.Int32 System.Decimal

Asks for a number.

Syntax

Read-ConsoleNumber [-Default <Decimal>] [-Description <String>] [-Integer] [-Maximum <Decimal>] [-Minimum <Decimal>] [-Mode <Rich|Line|Accessible>] [-ParameterName <String>] [-Step <Decimal>] [-Title] <String> [-Validate <ScriptBlock>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Asks for a number.

Whole numbers with -Integer (returns [int]), decimals otherwise (returns [decimal]). -Minimum and -Maximum are shown as a hint and checked; Up and Down step by -Step (PgUp and PgDn by ten steps).

Examples

Authored help example

EXAMPLE 1

Read-ConsoleNumber -Title 'Value'

Parameters

-Default Decimal optional
The default.
-Description String optional
Help text under the question.
-Integer SwitchParameter optional
Accepts whole numbers only and returns [int].
-Maximum Decimal optional
The largest value.
-Minimum Decimal optional
The smallest value.
-Mode InteractionMode optional
Forces how to ask: Rich (in-place prompt), Line (question and typed answer), Accessible (numbered, no redraws) or None (use the default or fail).
Possible values: Rich, Line, Accessible
-ParameterName String optionalaliases: Parameter
The parameter of your script that supplies this value without a prompt (named in the non-interactive error, for example -Domain).
-Step Decimal optional
The step of Up and Down (default 1).
-Title String requiredposition: 0aliases: Prompt, Question
The question.
-Validate ScriptBlock optional
A validator: $_ is the number; return $true, $false or an error message.

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.