Powershell工作流DynamicActivity编译器错误'。预期使用$ Date变量 [英] Powershell Workflow DynamicActivity Compiler Error '.' Expected Using $Date Variable

查看:410
本文介绍了Powershell工作流DynamicActivity编译器错误'。预期使用$ Date变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常powershell错误给我一些东西继续,但这一个让我通过一个循环。要测试,请执行以下代码:

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 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

真正得到我的部分是它说它期望在某个地方。不知道它希望找到一个'。'我已经google了这个错误,没有产生任何相关的我的情况。我想知道更多关于这个错误的意思,为什么我得到它

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.

推荐答案

我不知道实际的原因,但如果你将变量 $ date 重命名为 $ something_else ,工作流工作。

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

如:

Workflow Test-Date {
    $aDate = Get-Date Get-Date -format yyyyMMddHHmm
    $New_Date = Get-Date -format yyyyMMddHHmm

    Write-Output $aDate
    Write-Output $New_Date
}

我假设它在转换期间触发.NET中的关键字。

I assume it's triggering a keyword in .NET during the conversion.

这篇关于Powershell工作流DynamicActivity编译器错误'。预期使用$ Date变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆