The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Issue passing dynamic JSON data to PowerShell in workflow for AD integration

nehaaress
Tera Contributor

Hello Everyone,

I am working on integrating on-premise Active Directory with Service Now.

Here’s what I have done so far:

  • I created a catalog item where I collect username and password from the requester.

  • I built a workflow for this catalog item.

  • Inside the workflow, I am using the Run Power-Shell (Core activity) to create AD accounts.

  • I am passing all the required parameters into the script (e.g., Account_Name, password, etc.).

The issue I am facing:
👉 I am not able to pass the dynamic workflow data (scratchpad variables) in JSON format to my Power-Shell script.

  • When I try to build a JSON object, only static values seem to pass.

  • The workflow scratchpad values are not being substituted into the JSON payload.

Has anyone implemented something similar?

  • How can I pass workflow variables (like username, password) dynamically into a JSON object?

  • Do I need to handle this in the workflow script activity first and then pass as a single string parameter to Power-Shell ?

  • Or is there a way to directly inject workflow variables into the Run Power-Shell input parameters?

Any guidance or working examples would be really helpful 

Thanks in advance!

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@nehaaress 

it should get substituted properly.

You can use workflow run script to form the JSON string and then substitute.

share the script here along with screenshots.

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader