My goal is to end up with a syntax that looks like this:
Cmdlet [[-ReportStart] <DateTime> [-ReportEnd] <DateTime>] [<CommonParameters>]
The idea is that the Cmdlet can be run either with 0 or 2 parameters. If you specify ReportStart or ReportEnd, you must specify the other. If you specify neither, then the Cmdlet will use default values.
This is what I have so far, but this doesn't make the ReportDate set optional.
[CmdletBinding(SupportsShouldProcess=$False)] Param( [Parameter(ParameterSetName="ReportDate", Mandatory=$true, Position=0, ValueFromPipeline=$false)] [ValidateNotNullOrEmpty()] [DateTime] $ReportStart, [Parameter(ParameterSetName="ReportDate", Mandatory=$true, Position=1, ValueFromPipeline=$false)] [ValidateNotNullOrEmpty()] [DateTime] $ReportEnd )Any help is greatly appreciated!