异常调用" StartWorkflow"用" 3"参数:""

时间:2015-10-26 20:09:27

标签: powershell sharepoint workflow

我正在尝试编写一个启动两个工作流程的PowerShell脚本。

只需要启动一次,而另一个需要在列表中的每个项目上运行。然而,我被一个错误所困扰,我不知道如何摆脱它。当我添加一个4参数时,我得到了同样的错误。我将脚本作为spshelladmin

运行

错误

Exception calling "StartWorkflow" with "3" argument(s): ""
    At C:\cert.ps1:26 char: 29
    + $em = $manager.StartWorkFlow <<<< ($items[0],$emails,$data)
        + CategoryInfo           : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId  :  DotNetMethodException

代码

$web = Get-SPWeb -Identity "http://portal.com/sites/it" 
$manager = $web.Site.WorkFlowManager   
$list = $web.Lists["Certificate Tracking"]

$assoc = $list.WorkflowAssociations.GetAssociationByName("Certificate Notification","en-US")
$assoc.AllowAsyncManualStart = $true
$assoc.AllowManual = $true

$emails = $list.WorkflowAssociations.GetAssociationByName("Status Update","en-US")
$emails.AllowAsyncManualStart = $true
$emails.AllowManual = $true

$view = $list.Views["All Items"] #All Items
$items = $list.GetItems($view)  

$data = $assoc.AssociationData
$emData = $emails.AssociationData

$count = 0

foreach ($item in $items) {
 $wf = $manager.StartWorkFlow($item,$assoc,$data) 
}
$em = $manager.StartWorkFlow($items[0],$emails,$emData,$true)

$web.Dispose()

1 个答案:

答案 0 :(得分:0)

我实际上发现我定位的特定项目已经在其上运行了一个工作流程,我没有对状态进行适当的检查(查看对此代码http://paulryan.com.au/2014/cancel-all-workflows/的评论),非常误导性的错误,我以为我在StartWorkFlow ($item, $association, $data, $true)的方法调用上有错误的重载,在SP 2013中有4个参数不确定为什么线程标题说三个...无论如何希望能帮助某人。