Double Task on PowerShell start

  • 7 August 2017
  • 1 reply
  • 0 views

Badge +1

When I start the Workflow with a PowerShell script, then I got 2 tasks with the same name to complete.

The first one says no task ID found , the second one works. But the desired behaviour is only one task should appear.

When the workflow is started manually then there is only one task. The task is a simple confirmation.

Here is the  PowerShell code to call the Workflow:

$web = Get-SPWeb $mySiteUrl
$list = $web.Lists[$sDocLibraryName]
$wfm = $web.Site.WorkFlowManager
$association = $list.WorkFlowAssociations |Where { $_.Name -eq $WFName}
$data = $association.AssociationData

$wc=new-object system.net.webclient
$wc.Credentials = Import-Clixml $credentialsPath

$item = $list.GetItemById($listItemID);

$wf = $wfm.Startworkflow($item,$association, $data,$true)

Write-Host "Workflow started, please wait 10 seconds" -ForegroundColor Green;

Start-Sleep -Seconds 10

$web.Dispose();


1 reply

Badge +1

Did a test on a simple workflow with just a task and the PowerShell script started it with just one.

As the main workflow was pretty huge I've put a 5 min. wait action before the task and the problem was solved.

Reply