This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Parameters to script and back

Hello

I can't find any information about how to send parameter values from a workflow to a powershell script and back (after modifying them).

What I already tried to pass parametervalues to a script:

$testvar = $Workflow.Parameter("test")

$testvar = $Request.Parameter("test")

To get values FROM the script BACK to the workflow parameters:

$Workflow.Parameter("test) = $testvar

$Request.Parameter("test") = $testvar

I'd be very thankful for clarifications!

Best regards

PSnewb

  • I am having the exact same problem. 
    Reading parameter into the script works with $testvar = $Workflow.Parameter("test")
    but I cant get a script to modify the value of a parameter to user in a later workflow activity (if/else)

  • I don't think that this is an issue of parameterization, it is an issue of scope.

    If you have a variable which is created at the Global scope, it will be accessible within any script module within that Workflow.

    So, if I have a script module which assigns a variable with a global scope:

    function setGlobal($request)
    {
    
    $global:var = "Set"
    
    }

    I can then access that variable in a different script module within the same Workflow by simply referencing the variable name and the scope:

    function readGlobal($request)
    {
    $global:var | Out-File c:\temp\global.txt
    } 
     

    This writes the word "Set" to a file, as expected.

  • Terence, I kind of understand that, but will I be able to access that global variable as a condition for an If/Else?
    The myriad of options in available in activity config is overwhelming.

  • Yeah, that works just fine. I just tested it with a quick Workflow in my lab:

    The first branch fired and the file was created.