Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Code sample for this can be found in K2 Developer Reference
# 4.7:
# https://help.k2.com/onlinehelp/k2blackpearl/devref/4.7/default.htm#using_the_windows_powershell_to_start_a_k2_process.html
# 5.2:
# https://help.k2.com/onlinehelp/k2five/devref/5.2/default.htm#runtime/wf-client/ps-startprocess.html
$i = 0
$NumberOfInstancesToStart = 100000
$ProjectName = 'K2Project'
$WorkflowName = 'Process'
Do {
$i=$i+1
$FolioValue = "K2 process " + $i + " " + (Get-Date).Hour + ":" + (Get-Date).Minute + ":" + (Get-Date).Second
[System.Console]::WriteLine("Starting K2 process instance " + $FolioValue)
Add-Type -AssemblyName ('SourceCode.Workflow.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=16a2c5aaaa1b130d')
$conn = New-Object -TypeName SourceCode.Workflow.Client.Connection
$conn.Open("localhost")
$pi = $conn.CreateProcessInstance($ProjectName + "\" + $WorkflowName)
$pi.Folio = $FolioValue
$conn.StartProcessInstance($pi)
}
While ($i -lt $NumberOfInstancesToStart)
[System.Console]::WriteLine("Done: " + $i + " process instances started")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.