Archive for: ‘September 2013’

Create Runbook activities from Orchestrator

September 16, 2013 Posted by Anders Asp

Have you tried adding Runbook Activities to your Service Requests dynamic through Orchestrator? Depending on the information provided by the end user on the self-service portal you might want to automate different things or in different ways. So the idea here is to have a Service Request template containing one initial Runbook Activity that adds the rest of the activities to the actual Service Request, whether it’s Manual, Review or Runbook Activities.

Creating/addning Manual or Review activities through Orchestrator isn’t that complicated, as long as you remember to set some essential properties, such as Sequence ID or adding the prefix to ID. The challange comes when trying to add Runbook Activities to your Work Item.

Using the same approach as you do when creating Manual or Review Activities, this is how you would do it:

SS1This will create the Runbook Activity in the SR but if you want the Runbook Activity to function properly, you have to set some pretty complex parameters in the configuration of the “Create related RB activity”. It’s simply not manageable.

So how do we solve this? Well, how does it work from the console? When adding an activity to a Work Item, you actually have to select an activity template, and that’s exactly what we are going to do here as well. It’s just that we are going to apply the template to the Runbook Activity after it’s been created.

To do this we need SMLets ( and the “PS Script Execution” IP for Orchestrator ( I tend to use this IP to run SMLets on the SCSM mgmt. server when using SMLets from Orchestrator. Install SMLets on your SCSM management server and deploy and configure the “PS Script Execution” IP on your Orchestrator Runbook Server.

Now, let’s add two activities to our runbook – a “Get Object” activity from the SCSM IP to get the RB activity we just created, and a “Execute PS Script – Global” from the “PS Script Execution” IP.


I won’t go into details on how all activities are configured or used, as I think you already know that (if not, drop me a comment below and I’ll add more details!), but let’s take a closer look at the “Execute PS Script – Global” activity.


The activity is configured to call my SCSM mgmt. server where I have SMLets installed. The script I’m running to apply a template on the Runbook Activity itself is actually re-used from an earlier blogpost of mine ( and works really good. Using the Runbook Activity ID from the “Get RB” activity we can get the actual object using SMLets. Then we are getting the Runbook Automation Activity template by the displayname of the template itself. In this example the displayname of my template is “Runbook test” (due to lack of imagination 🙂 ). That’s the only two thing you have to reconfigure in this script to make it work!

Here’s the complete script for you to copy/paste:

Import-Module Smlets

$Projection = Get-SCSMTypeProjection Microsoft.SystemCenter.Orchestrator.RunbookAutomationActivity.Projection

$RBID = "RUNBOOK ACTIVITY ID FROM DATABUS" $RBObject = get-scsmobjectprojection $projection -filter "Id -eq $RBID"

$template = Get-SCSMObjectTemplate -displayname "Runbook test"

$RBObject.__base.ApplyTemplate($template) $RBObject.__base.Commit()

Remove-Module Smlets


Moving runbooks from one environment to another

September 9, 2013 Posted by Anders Asp

If you ever worked with Orchestrator in different environments you know the hassle with moving (export/import) Runbooks from one environment to another. In your pre-production environment the Integration Pack Connection settings is called one thing and in your production environment it’s called something else. This will cause the activities using that connection in your Runbooks to fail… Editing each activity manually to correct this is not an option as it will cause you to lose your activity configuration.


There’s a rather easy fix for this however, and that is simply to do a search and replace in the exported Runbook (*.ois_export file). Open the file with Notepad (right click it and select “Open with”) and now search for <Connection datatype=”string”>. This will take you to the section in which the Connection setting for a particular activity is specified. It will look something like this:


Note how the name of my Connection is specified within this codeblock. Now copy the marked section and do a search and replace. Make sure to replace the connection name with the name you are using in your production environment. In my case I would do this:

Search for:
<Connection datatype=”string”>SCSM 2012 Pre-prod</Connection>

Replace with:
<Connection datatype=”string”>SCSM 2012</Connection>

Repeat this step for all the different Integration Pack connection settings used in the Runbook. Then simply save the file and import it as usual in Orchestrator and everything should be perfectly fine.

So why is there a bold “should” in that sentence? Well, as I discovered the other day, my Runbooks would simply not import correctly after doing this procedure and I couldn’t figure out why. I had been doing this for a long time and now all of a sudden it didn’t work? It turned out that for some reason, after saving my edited Runbook export file in Notepad, the file encoding had changed and Orchestrator refused to read the file when trying to import it. All I had to do to fix this was to re-save the file in the correct file encoding: ANSI.


Hope this will save you some headache! 🙂

CSV update of Business Services

September 3, 2013 Posted by Alexander Axberg

In this post I will show how to make a bulk update of Service Owner and Serviced By User relations on specific Business Services.
Since these relations are located on the System.Service class, which is abstract, we can’t use a regular CSV import in Service Manager.

However, we can solve it with some Powershell magic and SMLets.

You need to start with installing SMLets and load it in a powershell console (‎)

Then you need to prepare your import data. It should be saved as a CSV-file with semicolon separation, and contain the following columns:

  • Displayname of the Business Service ; sAMAccountName of the Service Owner ; sAMAccountName of the Serviced By User

Here is one example of two rows:

Active Directory;user123;user456


  1. Name the CSV-file “input.csv” and put it in your c:\temp directory
  2. Copy the powershellscript to the same directory
  3. Run the script. The script will search for the displayname, and then update the relations for each row.
  4. All updated services will be logged to the file “updated.txt”
  5. If some service coudn’t be found and updated, they will be logged to “failed.txt”


Powershell script:

$input = Get-Content C:\temp\input.txt
$row = $null
$ServiceOwner_RelClass = Get-SCSMRelationshipClass System.ConfigItemOwnedByUser$
$ServiceResp_RelClass = Get-SCSMRelationshipClass System.ConfigItemServicedByUser$

Foreach ($row in $input)
$data = $null
$service_displayname = $null
$owner_user = $null
$resp_user = $null

$data = $row.Split(";")
$service_displayname = $data[0]
$owner_user = $data[1]
$resp_user = $data[2]

$service = $null
$row2 = $null
$ServiceOwner = $null
$ServiceResp = $null

#Check array for all columns
If ($data.Length -eq 3)
$service = get-scsmobject (get-scsmclass System.Service$) -Filter "Displayname -eq '$service_displayname'"

#Service not found?
If ($service -eq $null)
Write-Host "$service_displayname not found!" -ForegroundColor Red
$service_displayname | Out-File c:\temp\failed.txt -Append}

#Service found!
$service_displayname + " = " + $service.Displayname
$Service.Displayname | out-file c:\temp\updated.txt -Append
$ServiceOwner = Get-SCSMObject -Class (Get-SCSMClass Microsoft.AD.User$) -filter "Username -eq '$owner_user'"
$ServiceResp = Get-SCSMObject -Class (Get-SCSMClass Microsoft.AD.User$) -filter "Username -eq '$resp_user'"
New-SCSMRelationshipObject -Relationship $ServiceOwner_RelClass -Source $Service -Target $ServiceOwner -Bulk
New-SCSMRelationshipObject -Relationship $ServiceResp_RelClass -Source $Service -Target $ServiceResp -Bulk