Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Add-OfficeExcelValidationDate

Aliases: ExcelValidationDate
Module
PSWriteOffice
Aliases
ExcelValidationDate
Inputs
OfficeIMO.Excel.ExcelDocument

Adds a date data validation rule to a worksheet range.

Syntax

Add-OfficeExcelValidationDate
[-AllowBlank <Boolean>]
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-Formula1] <DateTime>
[-Formula2 <DateTime>]
[-HeaderName <String>]
[-HeaderRow <Int32>]
[-IncludeHeader]
[-Operator] <ExcelDataValidationOperator>
[-PassThru]
[[-Range] <String>]
[-TableName <String>]
[<CommonParameters>]
#
Parameter set: Context
Add-OfficeExcelValidationDate
[-AllowBlank <Boolean>]
-Document <ExcelDocument>
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-Formula1] <DateTime>
[-Formula2 <DateTime>]
[-HeaderName <String>]
[-HeaderRow <Int32>]
[-IncludeHeader]
[-Operator] <ExcelDataValidationOperator>
[-PassThru]
[[-Range] <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-TableName <String>]
[<CommonParameters>]
#
Parameter set: Document

Examples

Restrict values after a date.

ExcelSheet 'Data' { Add-OfficeExcelValidationDate -Range 'C2:C20' -Operator GreaterThan -Formula1 (Get-Date '2024-01-01') }

Ensures dates in C2:C20 are after 2024-01-01.

Parameters

-AllowBlank Boolean optional
Allow blank values.
-ErrorMessage String optional
Error message shown to the user.
-ErrorTitle String optional
Error title shown to the user.
-Formula1 DateTime requiredposition: 2
Primary date bound.
-Formula2 DateTime optional
Optional secondary date bound.
-HeaderName String optionalaliases: ColumnName
Header or table column name used to resolve the target range.
-HeaderRow Int32 optional
Worksheet header row used when resolving HeaderName without a table. Use 0 for the first row of the used range.
-IncludeHeader SwitchParameter optional
Include the header cell in the resolved range.
-Operator ExcelDataValidationOperator requiredposition: 1
Validation operator.
Possible values: Between, NotBetween, Equal, NotEqual, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual
-PassThru SwitchParameter optional
Emit the range string after applying validation.
-Range String optionalposition: 0
Target range in A1 notation.
-TableName String optional
Optional table name for header-based range resolution.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to operate on outside the DSL context.
-Sheet String optionalsets: Document
Worksheet name when using Document.
-SheetIndex Int32 optionalsets: Document
Worksheet index (0-based) when using Document.

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.