question

jansiranikrishnan-1796 avatar image
0 Votes"
jansiranikrishnan-1796 asked StefanHorz commented

How to see the value of a variable in Run .Net Script in an Orchestrator Runbook

Hi Team,

How to see the value of a variable from Powershell code (Run .Net Script)?

Sample Code:
$ResponseObject=Invoke-RESTMethod -Uri $URL method 'POST' -credential $CRED -body $JsonBody -ContentType 'application/json'

Here, I would like to see the value of the variable "ResponseObject" (which is the result from the web-service call). Can we achieve this using Published Data Tab? If Yes, Please let me know the steps to do the same.

Regards,
Jansi

msc-orchestrator
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered jansiranikrishnan-1796 commented

Hi @jansiranikrishnan-1796 ,

no problem ... this will work as well. Just add a new variable in your script like this:

 $ResponseObjectResult = $ResponseObject.Result

And add this to PublishedData :

Name: ResponseObjectResult
VariableName = ResponseObjectResult


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you so much Andreas. This works :)

0 Votes 0 ·
AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered StefanHorz commented

Hi @jansiranikrishnan-1796 ,

yes it can be done on the Published Data tab in the Run -Net Script activity.

Just add the variable of the PowerShell script without leading $. If I remember right this is case sensitive.

Looks like this:

 $result = "something"
 $Firstname = 'Peter'
 $Lastname = 'Pan'
 $EmailAddress = 'peter.pan@test.local'
 $userGUID = 'peter.pan'


98679-image.png


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten




image.png (78.7 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Andreas,

Thank you for your response. I tried the steps as above. But here, $ResponseObject is not just a variable, Instead it is an object and the actual response contains in $ResponseObject.Result. So, how to view the value for 'Result'

Any help is highly appreciated.

Regards,
Jansi

0 Votes 0 ·
StefanHorz avatar image StefanHorz jansiranikrishnan-1796 ·

Hi @jansiranikrishnan-1796,
in your script assign $ResponseObject.Result to $Result ($Result = $ResponseObject.Result) and add Result to Publish Data.
regards,
Stefan

0 Votes 0 ·