Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell Workflow DynamicActivity Compiler Error '.' Expected Using $Date Variable

Usually powershell errors give me something to go on, but this one has thrown me through a loop. To test, execute the following code:

workflow test-date{
    $Date = Get-Date -format yyyyMMddHHmm -Verbose

    Write-Output $Date
}

The error I get is:

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.

like image 729
Colyn1337 Avatar asked Feb 11 '23 02:02

Colyn1337


1 Answers

I don't know the actual cause, but if you rename the variable $date to $something_else, the workflow works.

Such as:

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.

like image 109
grefly Avatar answered Mar 23 '23 04:03

grefly