Script Service Manager SMA

SCSM – Adding Activities Using SMA / PowerShell Workflow

For the past couple of weeks I have been doing some automation stuff using Service Management Automation (SMA) and therefore PowerShell in conjunction with Service Manager. I like PowerShell very much, especially if I can interact with other systems. As you might know in the “old” days you would use Orchestrator and Service Manager to start your datacenter automation project.  This was very handy because you already had all parts delivered by Microsoft like Orchestrator Integration Packs to build your runbooks and also a connector to integrate the runbooks into Service Manager. In the current days you have SMA and Service Manager but no connector unless you use the SMA Connector from Cireson  combined with their Self-Service Portal to unleash the full power of all components (SCSM, SMA, PowerShell).

Depending on your automation / process you will sooner or later need to find a way to add dynamically activies (manual, review, parallel, sequential etc.) to your service request in Service Manager. Just to understand what I am talking about, here a screenshot of my service request…


I had the requirement to add dynamically a sequential activity into a given parallel activity and the sequential activity should contain a review activity followed by a SMA runbook activity. It should look like this…


In my case dynamically means, to trigger a PowerShell script / workflow (a certain number of times) which will create this basic activity framework. To fulfill this task I installed / will use the smlets from codeplex on the SCSM server.

The final workflow looks like this…


First I get the SCSM server name from a SMA Variable and the necessary credentials from a SMA PowerShell Credential Asset to access Service Manager, because I will use InlineScript which will execute the code remotely on the SCSM server itself. Next step, I define the relationship System.WorkItemContainsActivity$ which is the relationship that is used as soon an activity needs to be related to another activity. After that I get the service request from the provided input (SR ID), find the parallel activity (which is already glued to the service request) and then add the other activities in the required order. First sequential activity, then review activity and finally the SMA runbook activity.

If you run this code in your SMA environment a few times you will receive the following result.

Provide the service request id in SMA…


After the first run…


…after the second run…


I just stripped down the code to provide a simple example how you could do it using SMA / PowerShell workflow because there are many examples how you could do it in Orchestrator. Download the script sample from TechNet Gallery .

I hope this helps!

2 Replies to “SCSM – Adding Activities Using SMA / PowerShell Workflow

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.