Cmdlet
Test-OfficeExcelTemplate
Tests whether supplied values bind every template marker.
Syntax
Test-OfficeExcelTemplate
[-Document <ExcelDocument>]
[-Quiet]
-Value <Hashtable>
[<CommonParameters>]#Parameter set:
DocumentTest-OfficeExcelTemplate
[-Path] <String[]>
[-Quiet]
-Value <Hashtable>
[<CommonParameters>]#Parameter set:
PathTest-OfficeExcelTemplate
-LiteralPath <String[]>
[-Quiet]
-Value <Hashtable>
[<CommonParameters>]#Parameter set:
LiteralPathExamples
Check that values fill a template
Test-OfficeExcelTemplate -Path .\Templates\Service-Report.xltx -Value @{ Client = 'Northwind Traders'; Month = 'October 2026'; Availability = 0.9994 } -QuietReturns $true when the values bind every marker in the template.
Stop a report run when the template changed
$values = @{ Client = 'Northwind Traders'; Month = 'October 2026'; Availability = 0.9994 }
$report = Test-OfficeExcelTemplate -Path .\Templates\Service-Report.xltx -Value $values
$report.ToMarkdown() | Set-Content -Path .\Logs\Template-Binding.md
if (-not (Test-OfficeExcelTemplate -Path .\Templates\Service-Report.xltx -Value $values -Quiet)) {
throw 'The service report template has markers this script does not fill. See Logs\Template-Binding.md.'
}Writes a Markdown binding report for review and stops before generating the monthly reports if any marker is unbound.
Parameters
- -Document ExcelDocument
- Caller-owned workbook; omission uses the enclosing Excel content block.
- -Quiet SwitchParameter
- Returns a Boolean result instead of the native validation report.
- -Value Hashtable
- Value or values consumed by the selected operation.
- -Path String[]
- Workbook paths resolved with filesystem wildcard support.
- -LiteralPath String[]
- Literal workbook paths, including FileInfo.FullName and provider PSPath.
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.