Home Orchestrator
Options

Creating SCSM ticket with a runbook attached

Sean_TerrySean_Terry Customer Advanced IT Monkey ✭✭✭

I have created tickets without activities but never with a runbook. Have tried a couple of times but never managed to successfully map an existing runbook with parameters to it.

I found some old URLs but it never quite worked for me.

Answers

  • Options
    Geoff_RossGeoff_Ross Cireson Consultant O.G.

    Hi Sean,

    I'm assuming you mean programmatically - rather than just creating one.

    PowerShell ok? I have this function. You need a runbook template with the params already sorted and then you just create it on the Parent and apply the template.

    Function Create-RBA {
        Param (
            $ParentWI,
            [string]$TemplateName,
            [string]$Param,
            [string]$ComputerName
        )
        
        $SCSM = @{
            ComputerName = $ComputerName
        }
    
    
        $RelWorkItemContainsActivity = Get-SCSMRelationshipClass System.WorkItemContainsActivity$ @SCSM
        $Template = Get-SCSMObjectTemplate -DisplayName $TemplateName @SCSM
        $RBProjection = Get-SCSMTypeProjection Microsoft.SystemCenter.Orchestrator.RunbookAutomationActivity.Projection @SCSM
    
    
        [int32]$SequenceID = Get-NextAvailableSequenceID -WI $ParentWI @SCSM
    
    
        $Projection = @{
            __Class = "Microsoft.SystemCenter.Orchestrator.RunbookAutomationActivity";
            __Object = @{
                SequenceID = $SequenceID;
                Text1 = $Param
                Status = "Pending";
                Id = "RB{0}";
            }
            ParentWorkItem = $ParentWI;
        }
     
        $RBObj = New-SCSMObjectProjection -Type Microsoft.SystemCenter.Orchestrator.RunbookAutomationActivity.Projection -Projection $Projection -PassThru @SCSM
    
    
        $RBA = $RBobj.Object
        
        $RBObject = Get-SCSMObjectProjection $RBProjection -filter "Id -eq $($RBA.Name)" @SCSM
         
        $RBObject.__base.ApplyTemplate($Template)
        $RBObject.__base.Commit()
    
    
        Return $RBA
    }
    

    Geoff

  • Options
    Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    What exactly doesn't work?

    If you create a runbook automation activity template, you have the possibility to map a workitem value to the parameter list.

    So you could e.g. map the ID or the Guid to that parameter, depending on what you need.

    And then you have to add the RB Activity to the IR template:


  • Options
    Sean_TerrySean_Terry Customer Advanced IT Monkey ✭✭✭

    @Simon_Zeinhofer Thanks for the reply. I think @Geoff_Ross may have provided me with a solution. It was using Orchestrator to create a new ticket with a related runbook.

    I could get Orchestrator to create the ticket and have a runbook activity, but couldn't get the runbook name and parameters into the newly created activity.

    Thanks @Geoff_Ross. I will give it a try when I can.

Sign In or Register to comment.