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

jansi rani krishnan 601 Reputation points
2021-05-21T14:58:23.18+00:00

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

System Center Orchestrator
System Center Orchestrator
A family of System Center products that provide an automation platform for orchestrating and integrating both Microsoft and non-Microsoft IT tools.
217 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 98,621 Reputation points MVP
    2021-05-21T17:39:49.43+00:00

    Hi @jansi rani krishnan ,

    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 additional answer

Sort by: Most helpful
  1. Andreas Baumgarten 98,621 Reputation points MVP
    2021-05-21T16:24:09.677+00:00

    Hi @jansi rani krishnan ,

    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