Cmdlet
New-ConsoleDatePicker
Creates a persistent civil-date or inclusive range picker.
Syntax
New-ConsoleDatePicker
[-Disabled]
[-Key] <String>
[[-Label] <String>]
[-OnChange <ScriptBlock>]
[-Range]
[-Selection <DateSelectionOptions>]
[-TabIndex <Int32>]
[-ValidationMessage <String>]
[-Value <Object>]
[<CommonParameters>]#Parameter set:
All Parameter SetsDescription
Uses Gregorian arithmetic with culture-aware labels. Arrows move the cursor, PageUp/PageDown change month, Ctrl+PageUp/PageDown change year, and Enter commits. In range mode Space anchors a range and Shift+arrows extend it. Bounds and unavailable dates reject a whole invalid range.
Examples
Example 1
New-ConsoleDatePicker -Key Window -Range -Value ([datetime]'2026-10-08')Choose a maintenance range.
Parameters
- -Disabled SwitchParameter
- Disables editing and removes the input from keyboard focus traversal.
- -Key String
- Unique key in the application's state and final hashtable.
- -Label String
- Visible label; defaults to the name using the core control's labels.
- -OnChange ScriptBlock
- Runs once per committed edit on the owning input thread. Receives param($Value, $State) and injected $Value, $State and $Control. State is a hashtable; add or assign keys to write back. Output is discarded. Retains closure variables.
- -Range SwitchParameter
- Commits one inclusive DateRange.
- -Selection DateSelectionOptions
- Shared bounds, culture, today and marked-day model.
- -TabIndex Int32
- Keyboard focus order. Equal values preserve layout declaration order.
- -ValidationMessage String
- Initial validation text displayed below the input.
- -Value Object
- Initial DateTime or DateRange; a scalar range default means Start=End.
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.