K2 Management Shell

  • 15 December 2017
  • 6 replies



The K2 Management Shell provides PowerShell cmdlets as wrapper around the K2 API?s so that administrators and developers can more easily manipulate K2 in a programmatic fashion. This solution was developed specifically for K2 4.7 and K2 Five. The cmdlets have not been tested with previous versions and there are no plans to make it work with older versions. It has been tested on Server 2012 R2 and Server 2016 and requires .Net Framework 4.6.1. This solution is provided as-is and should be tested before being put to use in any production environment. The cmdlets are fully functional and will work with other common PowerShell commands (i.e. Select-Object, Where-Object, Sort-Object). Any cmdlets that accept input from the pipeline will also be called out in the description of the parameters they use.


This solution was developed to minimize activities that would usually require manual database changes or read access to the K2 database. Since all cmdlets use the underlying K2 API there are no permissions required to the K2 database. This also means that all permissions specified in K2 apply to the user executing the cmdlets. For example, if the user executing Get-K2ProcessInstance doesn?t have rights to a particular process they will not see it listed.

The next step for this solution is to eliminate the need for manually changing configuration files on the K2 server. For now, only common configuration change related cmdlets are available but more will be added in the future. As this will require rights to update these files the logged in user will need administrative rights on the K2 server.




Inside the zip file with this solution you will find a file called installK2ManagementShell.ps1. This script will deploy the dll to the GAC and will create the needed folder structure on the K2 server. It should be run on the K2 server as it will connect to the local machine. If your environment has a separate tier for the K2 application layer you will need to install it there.


Once that has been run it will place a shortcut on your desktop which will automatically load module needed to run the K2 PowerShell cmdlets. This shortcut will also load the OOB snap-in provided for the Deploy-Package and Write-DeploymentConfig cmdlets. Alternatively, the module can be manually imported once the installation script has been run by using the following cmdlet in the PowerShell console:


Import-Module K2ManagementShell.dll

6 replies

Hi, where can I download the Management Shell or the maybe the source code? Thanks Steffen
Badge +6

Why does the cmdlet "Get-K2ProcessInstance" not work for me?


It give me the following error:
K2 Management Shell Error: 'ClientException: 28018 K2:DOMAINUSER does not have permissions to open the process
at SourceCode.Workflow.Client.InternalConnection.Call(ArchiveX ar, MessageType msgtype)
at SourceCode.Workflow.Client.Connection.OpenProcessInstance(Int32 ID)
at K2ManagementShell.GetK2ProcessInstance.ProcessRecord()'


What authority am I missing?


EDIT: In fact none of our Users can do this. Even the K2 Admin and Service Users... strange, isn't it?

Userlevel 2
Badge +6

The reason you're getting that error is because the user does not have "Process Rights" on the process you're trying to retrieve.

Go to K2 Management, find the Process under "Workflow Server", go to the Process Rights tab, then add the user who is executing this cmdlet there.

Kind regards,

Badge +6


that is strange but I have Process Rights (all available) - or do I need process rights for every process?



Badge +6

I found the problem. Indeed I did not have enough auhtorization for every workflow in the system... It is working now and I can proceed...

Userlevel 2
Badge +6
Hi Johann,

Per definition, "Process Rights" apply to every separate process.

The Authorization Framework also plays a role in K2 Five 5.3 (Category Security).

You can use K2 Roles or AD Groups to assign rights to several users at once.

Kind regards,