Reputation: 2866
In PowerShell 2 I have a function Get-CurrentQuarter that returns the current quarter.
I have another function that takes the parameter quarter. I'd like it to default to the current quarter using the function Get-CurrentQuarter.
I tried:
function Test-ParameterByFunction
{
param(
[string]$quarter = Get-CurrentQuarter
)
}
Test-ParameterByFunction
PowerShell reported:
PS > .\test.ps1
Missing expression after '='.
At .\test.ps1:4 char:23
+ [string]$quarter = <<<< Get-CurrentQuarter
+ CategoryInfo : ParserError: (=:String) [], ParseException
+ FullyQualifiedErrorId : MissingExpressionAfterToken
This would be really handy in cleaning up my code. Is there some syntax I'm missing?
Thanks!
Upvotes: 0
Views: 568