Creating custom workflow steps in Powershell

Loading a step

Custom workflow steps written in PowerShell can be loaded into emdash and used within the workflow engine.  The facility is available for users in the Admin role and is accessed from the Steps menu option.

In the Deployment steps page click the Add Step button

This takes you to the Create step page.  Select Powershell Script as the Type of step.  Then click the Select a file button to select the PowerShell script file containing the custom step code from the local file system.

Selecting a file will automatically populate the Step name and Step version fields.  These are populated from variables called $emdashStepName and $emdashStepVersion which must be present within the script file.  These variables are used to define the name of the step and its version.  An example of the code to populate these within your step is as follows:

$emdashStepName="Successful Step 1"

You will end up with a page looking something like this assuming you selected a PowerShell script file called "Successful Step 1.ps1"

The final step is to click the Save step button.  This will save the custom step to the emdash database.

Validation for custom step scripts.

When the Save step button is clicked emdash performs the following validation

  • The script must be valid PowerShell code.  Invalid code will be rejected with an error message indicating the cause of the error.
  • A parameter called $ctx of type emDash.Workflow.Step.Interface.PowershellContext must be included in the parameter block of the script. This allows access to the workflow context e.g. to use emdash workflow logging.
  • Other parameters must be of type int, stringboolean or DateTime.  Parameters can include a help message which will be available to the user in the emdash user interface when they run workflows based on the step.
  • The Step name and Step version entered in the user interface must match the $emdashStepName and $emdashStepVersion variables within the script.
  • An existing step with the same name must not exist.
  • It is possible to apply a ValidateSet attribute to parameters e.g. the following declaration will limit a Dynamic parameter to the values listed - this is enforced on the Create Job page via a drop down list.


Updating an existing step

It is possible to update a custom step using the update icon in the Deployment steps page:

The user may select a new file containing the updated version of the script.  The $emdashStepName variable in the script must match the name of the step being modified and the $emdashStepVersion variable must be a value that does not already exist in emdash.

Custom step template

Template steps are available in folder C:\emdash\help\Samples .  These show the various types of parameters that are supported and standard exception handling.  Note that the emdash workflow engine treats a return value of true as indicating that the step was successful.  A return value of false indicates failure.



Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk