MIM WAL: Run PS script outside the Workflow engine: Passing parameters from your script to WorkFlowData

See this blogpost on how to tun PS scrips inside and outside the workflow engine.

Single value return

You have to do this from inside your PS script. Just do a return from your script

  1. Declare a variable in the WorkflowData library

  1. In your code, return the result with the same name as the variable with a prefix “$”

$myOutput = “5551234”

Return $myOutput

Access in the WorkflowData library


Multiple value return

The MIM WAL documentation says return a hashtable of results. This works when the script runs inside the Workflow but when the PS is run outside I discovered that the hashtable returned gets corrupted on the way back, you end up with a strange array table that’s a collections of single records.


$MyProd = “6789955”

$MyProd2 = “455678”


Return $mytable


I get this return value for $mytable

Looks like an array of screen shots of my records


You have to create an array of results in your PS, return it and then convert it a hashtable in your code

In the script

$MyProd = “6789955”

$MyProd2 = “455678”


Return $PSmytable


In the Workflow

$mytablelist=Powershell -version 3.0 c:\myscripts\test1.ps1


for ( $i = 0; $i -lt $mytablelist.Length; $i += 2 ) {



Return $mytable


The result returned ($mytablelist) will look like this

This is then successfully converted to a hashtable and you can access it in the Workflowdata library in subsequent activities