Setting the Orchestrator Runbook properties

jansi rani krishnan 601 Reputation points
2021-06-24T19:27:42.887+00:00

Hi Experts,

I have created a Runbook with below two activities.

  1. Initialize Data
  2. Run .Net Script

Please find attached the screenshots for the Runbook properties.

109143-image.png
109154-image.png

Based on the input values received in the Initialize Data activity, I wanted to do some action in the PowerShell script as follows.

$IC=get-scsmclass -name system.workitem.incident$  
$IO=get-scsmobject -class $IC -filter "Id -eq $IRId"  
  
if($Urgency -ne "NULL")  
{  
Set-SCSMObject -SMObject $IO -Property "Urgency" -value $Urgency  
}  

it is throwing an error as "cannot bind SMObject as it is null"

How to check the values of the input data received in "Initialize Data" activity.

I also tried by clicking the warning message and found the below information.
109106-image.png

Any help is highly appreciated.

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.
219 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 104K Reputation points MVP
    2021-06-25T09:24:03.433+00:00

    Hi @jansi rani krishnan ,

    add all required variables of the PowerShell script to the Returned Data -> name of the PS variable without the $

    109256-image.png

    Open the Properties of the Runbook and click Logging select marked options

    109279-image.png

    After the Runbook finished click on the job in the Log History
    Open the Initialize Data Activity and select the Published Data information you defined for Input

    109289-image.png

    There you can see the value of the Input parameter

    Same way you can see the Published Data of the Run .Net Script activity

    ----------

    (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 104K Reputation points MVP
    2021-06-24T19:57:58.217+00:00

    Hi @jansi rani krishnan ,

    error message = $IO=get-scsmobject -class $IC -filter "Id -eq $IRId" -> no incident object found / $IO is empty
    You should check the value of $IRid if it is an existing IR in SCSM

    You should implement a small error handling in your PowerShell script. Just an idea:

     # .... not sure if there is more code before  
          
    $IC = get-scsmclass -name system.workitem.incident$  
    $IO = get-scsmobject -class $IC -filter "Id -eq $IRId"  
    if ($Urgency -and $IO) { # Check if $Urgency and $IO has a value  
        $result = "Urgency and IO not empty"   
        Set-SCSMObject -SMObject $IO -Property "Urgency" -value $Urgency  
    }  
    else { $result = "Urgency or IO empty" }  
    

    In the Run .Net Script activity at Published Data add three variables:
    result
    IRid
    Urgency

    This way you can see the values of all three variables after the Runbook finished.

    ----------

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

    Regards
    Andreas Baumgarten