Question:
Usually powershell errors give me something to go on, but this one has thrown me through a loop. To test, execute the following code:
1 2 3 4 5 6 |
workflow test-date{ $Date = Get-Date -format yyyyMMddHHmm -Verbose Write-Output $Date } |
The error I get is:
1 2 3 4 5 6 7 8 9 |
The workflow 'test-date' could not be started: The following errors were encountered while processing the workflow tree: 'DynamicActivity': The private implementation of activity '1: DynamicActivity' has the following validation error: Compiler error(s) encountered processing expression "Date". '.' expected. At line:383 char:21 + throw (New-Object System.Management.Automation.ErrorRecord $ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (System.Manageme...etersDictionary:PSBoundParametersDictionary) [], RuntimeException + FullyQualifiedErrorId : StartWorkflow.InvalidArgument |
The part that really get’s me is that it says it’s expecting a “.” somewhere. I don’t know where it’s expecting to find a ‘.’. I’ve googled the error which didn’t produce anything relevant to my situation. I’d like to know more about what this error means, and why I’m getting it. It’d be nice if someone knows the solution too.
Answer:
I don’t know the actual cause, but if you rename the variable $date
to $something_else
, the workflow works.
Such as:
1 2 3 4 5 6 7 8 |
Workflow Test-Date { $aDate = Get-Date Get-Date -format yyyyMMddHHmm $New_Date = Get-Date -format yyyyMMddHHmm Write-Output $aDate Write-Output $New_Date } |
I assume it’s triggering a keyword in .NET during the conversion.