Cmdlet
Read-ConsoleDate
Asks for one civil date or inclusive date range.
Syntax
Read-ConsoleDate
[-Default <Object>]
[-Description <String>]
[-InputObject <PSObject>]
[-Mode <Rich| Line| Accessible>]
[-ParameterName <String>]
[-Range]
[-Selection <DateSelectionOptions>]
[-StaticSnapshot]
[-Title] <String>
[<CommonParameters>]#Parameter set:
All Parameter SetsDescription
Returns one DateTime at midnight with unspecified kind, or one DateRange with -Range. Escape follows the normal prompt cancellation policy. Line and accessible modes accept yyyy-MM-dd and culture-aware dates; non-interactive mode requires a valid explicit default.
Examples
Example 1
Read-ConsoleDate -Title Window -Range -Default ([datetime]'2026-10-08')Read an inclusive maintenance window.
Parameters
- -Default Object
- Default DateTime or DateRange, validated even in non-interactive mode.
- -Description String
- Help text under the question.
- -InputObject PSObject
- Optional dated status records, using Date, Status and Label members.
- -Mode InteractionMode
- 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
- The parameter of your script that supplies this value without a prompt (named in the non-interactive error, for example -Domain).
- -Range SwitchParameter
- Returns one inclusive DateRange.
- -Selection DateSelectionOptions
- Shared date bounds, culture, today and immutable marked-day model.
- -StaticSnapshot SwitchParameter
- Prints the initialized rich prompt without reading input or returning an answer. Useful for documentation and unattended previews.
- -Title String
- The question.
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.