How to get parameters from PowerShell to Workflow ScratchPad

mallikarjun2
Giga Contributor

Hi,

How can I get parameter from PowerShell and store it in Workflow.Scratchpad

I can do the reverse, like

$fullUrl = '${workflow.scratchpad.inputurl}';

but

${workflow.scratchpad.inputurl} = $powerShellvariable; \

fails.

Can anyone please tell me the right way?

1 ACCEPTED SOLUTION

Hey Kenny!



Thanks for your response.


I already sorted that as follow:



For passing multiple parameters from PowerShell to Service Now, use the following syntax:



Write-Output "%%out_data1%%"


Write-Output "$($fullUrl)"


Write-Output "%%"



Here "out_data1" tag is the one which Service Now will use to read the variables.


$fullUrl is the parameter you want to return to Service Now.



You can have multiple return output blocks anywhere in your PowerShell script.



For example if you wana pass 2 parameters ($fullUrl and $baseUrl   )from PS to Service Now, you will write something like this:



Write-Output "%%out_data1%%"


Write-Output "$($fullUrl)"


Write-Output "%%"



Write-Output "%%out_data2%%"


Write-Output "$($baseUrl)"


Write-Output "%%"



Service Now will read these parameters using tags.fullUrl or tags.baseUrl in the Sensor script portion of PowerShell Activity.




Thanks!!


View solution in original post

3 REPLIES 3

Kenny Wimberly
Tera Guru

Hi, Mallikarjun.



In the Sensor script portion of the run powershell script activity, type the following to get what you need:



workflow.scratchpad.inputurl = trim(activity.output);



This is assuming of course that the output of the command in powershell is the inputurl.



Hope this helps!


Hey Kenny!



Thanks for your response.


I already sorted that as follow:



For passing multiple parameters from PowerShell to Service Now, use the following syntax:



Write-Output "%%out_data1%%"


Write-Output "$($fullUrl)"


Write-Output "%%"



Here "out_data1" tag is the one which Service Now will use to read the variables.


$fullUrl is the parameter you want to return to Service Now.



You can have multiple return output blocks anywhere in your PowerShell script.



For example if you wana pass 2 parameters ($fullUrl and $baseUrl   )from PS to Service Now, you will write something like this:



Write-Output "%%out_data1%%"


Write-Output "$($fullUrl)"


Write-Output "%%"



Write-Output "%%out_data2%%"


Write-Output "$($baseUrl)"


Write-Output "%%"



Service Now will read these parameters using tags.fullUrl or tags.baseUrl in the Sensor script portion of PowerShell Activity.




Thanks!!


Can I have overview of this action.

SInce I have an requirement to execute powershell script in servicenow