How to run a PS script with many inputs, through Flow Designer/PS Step Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 12:07 PM
I've created a Powershell step, and I'm trying to get the actual script to run. I can run all kinds of simple PS, and have no issue passing a handful of input variables that then get used by the script.
Challenge: The script I need to use has a lot of potential inputs, up to 39 in total.
How can I send these inputs from the Flow, to the Action.
Right now, I am sending them in a string, ie:
var psParms = "-input1 value1 -input2 value2... -input39 value39"
Then I send psParms to my action as the single input, and try to use the script, "run-script.ps1 $psparms" in the action, to no avail.
What I think I am running into, is that no matter how I try to add that string to the script, it sees it as a string type, rather than the switches for the PS script.
Is there a simple way to take that string, and have it be the parameters for that PS1 script?
- Labels:
-
IntegrationHub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 06:28 AM
We are using multiple ways:
1. as simple inputs to PS step
2. as JSON block
3. as array
4. as comma or other char separated string
Hope it helps.
Alex

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 07:13 AM
Instead of passing the values as "-input1 value1 -input2 value2... -input39 value39", you try following,
$psParms = "input1=value1
input2=value2
input39=value39"
$props = ConvertFrom-StringData $psParms
run-script.ps1 @props
Note: There is new line after each input=value.
Hope it helps!!
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2022 04:44 AM
I don't think this will help, since the maximum number of PS input variables is 19, and I have 39 of them.
I could be missing something here, though. i'll try it, since I think I've tried everything else so far lol
I can try sending it as JSON, since that's a valid input type, then converting back, but I'm still not sure how that will help with having 39 potential values.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2022 08:31 AM
We have a system property to increase the input variables limit, this should help for PowerShell step as well. Details below,
Maximum script variables per Script step sn_flow_designer.max_script_variables | Specify the maximum number of input and output variables that can be added to a Script step. Flow Designer prevents you from adding further script variables after the maximum number of variables has been reached. Consider the performance impact raising the maximum number of script variables may have. For example, processing more script variables may risk the Script step running for more than an hour and being stopped by the default transaction quota rule.
|
Link: https://docs.servicenow.com/en-US/bundle/sandiego-servicenow-platform/page/administer/flow-designer/reference/flow-designer-system-properties.html
Hope it helps!!
Please Mark ✅ Correct/helpful, if applicable, Thanks!!