I've read widely that I can pass in an argument to my powershell script via:
param (
[Datetime]$argument
)
I've also read that I can define a default value:
param (
[Datetime]$argument = Get-Date "5/1/2006 7:00 AM"
)
However on doing this I get:
At C:\Users\medmondson\Desktop\Scripts\ScrumTimer.ps1:2 char:26 + [Datetime]$argument = Get-Date "5/1/2006 7:00 AM" + ~ Missing expression after '='. At C:\Users\medmondson\Desktop\Scripts\ScrumTimer.ps1:2 char:24 + [Datetime]$argument = Get-Date "5/1/2006 7:00 AM" + ~ Missing ')' in function parameter list. At C:\Users\medmondson\Desktop\Scripts\ScrumTimer.ps1:3 char:1 + ) + ~ Unexpected token ')' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingExpressionAfterToken
This only appears to occur for DateTime
, any idea where I'm going wrong?
try enclose value in ()
param (
[Datetime]$argument = (Get-Date "5/1/2006 7:00 AM")
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With