Service Manager Workflows – Part 1

To automate tasks, Service Manager brings it’s own Workflow Engine. Using the Authoring Tool you can build detailed Workflows to automate almost any task you want. And the best thing: it’s pretty easy! In this Blogpost Series i will show you how Workflows can make your life easier …

I will build a Workflow that launches a Powershell-Script that automatically closes Incidents that have been in a resolved state for more than 5 days. You can find details about this Script in this Blogpost.

First, I create a new Management Pack in the Authoring Tool and create a new Workflow.

image

image

After the name and description of the Workflow have been specified, I choose the Workflow trigger. I want the Workflow to automatically run daily at a specific time.

image

image

Now it’s time to build the workflow. In this first Part of the Workflow Series, I will build a very simple Workflow with just one Object that holds the Powershell-Script. I just drag the needed Object from the Toolbox to the Workflow and configure it by giving it a name, description and the script body.

image

image

image

Now it’s time to save and import the Management Pack. But wait – there is one more step! The folder that contains the Management Pack XML-File also contains some other files that were created when I built the workflow. The Assembly (DLL-File) needs to be copied to the Service Manager Installation Folder on the Management Servers. Otherwise the Workflow will fail.

image

In the Service Manager Console it’s possible to check the Status of the Workflows. In case of problems you can find important details why the workflow did not run successfully.

image

In the next Part of the Workflow Series I will show you how to use Workflows for more complex requirements.

See you!
Marcel

This entry was posted in SCSM and tagged , , , , , . Bookmark the permalink.

8 Responses to Service Manager Workflows – Part 1

  1. Anand says:

    Hello Marcel

    I have created a workflow with Authoring Tool that has one PowerShell script included.The script is suppose to Update Activities related to a specific Change Request .

    I am able to import the Management pack and put the related files (*.dll) etc on the Service manager install dir. The workflow status says Succeeded but the script it seems does not run at all as there are no changes to the Change Request.

    I must add that when run from the PowerShell the script works and runs fine.

    Any pointers in this regard will be highly appreciated

    Thanks

    Anand

  2. ch says:

    hi,

    how to overwrite a workitem without triggering the update workflow?

    Thanks

  3. Tracy says:

    Hi Marcel, I receive an error when saving the MP though I did the steps you have described. I have copy and paste your code with a Little modification:

    $LogFilename = “C:\Install\Scripts\Logs\AutoCloseIncidentsScript.log”;

    $Date = (get-date);
    $DateString = $Date.toString();

    import-module smlets;
    $7DaysOld = (get-date).addhours(-168);

    $IncidentsToClose = Get-SCSMObject –ClassName System.WorkItem.Incident$ | where{$_.lastmodified -lt $7DaysOld -AND $_.Status -like “*Resol*”};

    $IncidentsToClose | Set-SCSMObject –property Status –Value Closed;

    Add-Content -Path $LogFilename ($Datestring + ” – ” + $IncidentsToClose.Count + ” Incidents AutoClosed”);

    When trying to save the MP there is an error: Incorrect sign in the coding, row 2, Position 457.

    • 1. Did you copy/paste the script? That could be the problem.
      2. The script is very old and a really good example how a script should NOT look like. It’s an old example from my first SCSM experience, so take care 🙂

  4. Marcelo Souza says:

    Hi Marcel

    If I run the script on powershell command line, on the management server, it works. But when I create the workflow and Import the script (or type it), the workflow status says it succeed, but nothing happens. I recreated it many times, but nothing happens, although the script works out of the workflow. Do you have an idea what is going on? I have SCSM 2012 R2 UR4.

    Thanks.

    Marcelo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s