Service Request Load Testing for SCSM

Posted: September 11, 2013 in Service Manager, System Center
Tags: , , , , ,

I have found a great for load testing SCSM with Incidents. The script uses SMLets to generate Incidents and you can then gauge how your system would handle the load you are planning within your Production Environment.

I will not go into the detail of the script as this blog post does a great job of explaining it. SO this got me to thinking about other Load Testing you could perform. The most common Load Test is with Incidents. However, i decided that another good load test would be Service Requests. What is nice about this load test, is that it uses a Management Pack which I have included in this post. The Management Pack contains a Service Request Template with a Manual Activity added as the first Activity. This will allow you to test Service Requests and well as Activities, which would in turn, test any workflows or runbooks that you have configured.

For my environment, i have additional runbooks which are also triggered when Manual Activities are completed or when Review Activities are completed. So with this Load Test script it also test my runbooks and other workflows.

Remember, to set a different Implementer for the Manual Activity to allow the runbooks or workflows to be triggered off correctly. Remember, no Manual Activity Implementer or if the implementer has no email address, your emails will not be triggered correctly. Below, is a breakdown of the script I am using.


#SMLets is needed for the script to work
Import-Module SMlets

#the number of Service requests to be created
$SRCount = 10

#the delay between attempts
$delay = 10

# Display Start Time
$StartTime = get-date
Write-Host "Started"
Write-Host $StartTime
Write-Host "-------------------`n"
Write-Host "Creating Service Request"
Write-Host "-------------------"
$i =1

while ($i -le $SRCount)

#Variable / Class Setup
$srClass = Get-SCSMClass -name System.WorkItem.ServiceRequest$
$srprior = Get-SCSMEnumeration -Name ServiceRequestPriorityEnum.Medium
$srurg = Get-SCSMEnumeration -Name ServiceRequestUrgencyEnum.Medium
$ararea = get-SCSMEnumeration -Name ServiceRequestAreaEnum.Other

#building your own SR Title
$title = "Fletcher Load Testing $i - " + (get-date)

#Service Request Arguements
$srargs = @{
Title = $title;
Urgency = $srurg;
Priority = $srprior;
ID = “SR{0}”;
Area = $ararea;
Description = “Created by Script”

#Create Service Request
New-SCSMOBject -Class $srClass -PropertyHashtable $srargs

#Get Projection & Object for Created Service Request
$srTypeProjection = Get-SCSMTypeProjection -name System.WorkItem.ServiceRequestProjection$
$SRProj = Get-scsmobjectprojection -ProjectionName $srTypeProjection.Name -filter “title -eq $title”

#Get Template
$template = Get-SCSMObjectTemplate -DisplayName "Load Test SR Template"

#Set Template
Set-SCSMObjectTemplate -Projection $SRProj -Template $template
$SR = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$) -filter "Title -eq $title"
$SRName = $
$SRTitle = $SR.Title
Write-Host $SRName " - " $SRTitle

# Pause before creating next SR
Start-Sleep -s 5

#getting the above created Service Request
$ServiceRequestToUpdate = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$) -Filter "Id -eq $SRName"

#get the Realted Child Manual Activity
$ChildActivities = (Get-SCSMRelationshipObject -BySource $ServiceRequestToUpdate | ?{$_.RelationshipID -eq "2DA498BE-0485-B2B2-D520-6EBD1698E61B"})

$get the ID Value
$MAIDToUpdate = $ChildActivities.targetobject.values[9].value

#getting the MA Class
$Class = Get-SCSMClass -Name System.WorkItem.Activity.ManualActivity

#getting the "Active" Status
$StatusActive = Get-SCSMEnumeration -name ActivityStatusEnum.Active

$Activity = Get-SCSMObject -Class $Class | ? {$_.ID -eq $MAIDToUpdate}

#setting MA to Active
Set-SCSMObject -SMObject $Activity -Property "Status" -Value $StatusActive

#showing current status
Write-host $MAIDToUpdate " is now " $StatusActive
$i +=1
Start-Sleep -s $delay

# Display End Time
Write-Host "_______________________`n"
$EndTime = get-date
Write-Host = "Finished"
Write-Host $EndTime
#End of Script

The script can also be downloaded from the Technet Gallery here.

(E-Mail me)

Follow me.

Facebook (Personal)

Twitter (Personal & System Centre)

Twitter (System Centre Focused)

  1. Iris says:

    hey, i need to create a Service Request by a Template and because of that i wanted to use a part of this script. Everything seems to work first, but when i put it into an .Net Script Activity in my runbook it has some problems to find the created SR.The variable SRProj always stays NULL and then it is not possible to create the Projection in the step to apply the Template.
    //Set-SCSMObjectTemplate -Projection $SRProj -Template $template
    I filtered the Service Request by Title, and it´s an unique name because i added an ID from a related SR.
    //$title=” Lizenzprüfung von {ID from “Get SR”}”
    It´s always the same error Message: “cannot bind argument to parameter ‘Projection’ because it is null.”
    In Service Manager the new Service Request is created, but the Template isn´t applied.

    I tried a lot, but i dont get any output for SRProj, do you have any ideas?!
    Thank you

    • Ok, so you are using orchestrator.
      Have you installed SMLets and for ease, the SM Console on the orchestrator server. there are also a few additional steps to follow. See here,
      The way I test is put to append my code to a text file and run it natively in PowerShell.
      Also, Orchestrator runs a 32 bit version of PowerShell.

      Basically, it would appear that the Title you are getting from the Data Bus is wrong or empty.

      • Iris says:

        yes, i am using Orchestrator. I installed smlets and set the Policies and i also connected the requiered .dll`s from SM Server to the assemblies on the Orchestrator Server. In powershell i can use the smlets, so i think it hast to work and they are properly installed.
        i also test my runbooks by appending my output in a text file. It does grab the right title, thats why i don´t understand, why my result is still null after filtering.

  2. can you post a copy of the text being appended to a text file?

    • Iris says:

      Ok, thank u! But I think the problem occurred one step later when using the projection in ‘set-scsmobjecttemplate’ the variable SRProj is null, so it doesn’t find a matching service request in the projection. The template I want to apply is found like u could see in the text file …;(

  3. Iris says:

    i set my $title=”Lizenz Kostenstellenpruefung Von {ID from “Ger SR”}

    when i run my script in orchestrator and comment the set template line, it runs successfully and i get my output variables in the text file:

    Title:Lizenz Kostenstellenpruefung Von SR1181
    Template: Template.8d8ee679549d41c5a25e3f840386ed80

    so there s no value found at grabSRequest, thats ur Variable SRProj

  4. Hi,
    If you look at the code below,
    #Get Template
    $template = Get-SCSMObjectTemplate -DisplayName “Load Test SR Template”
    The easiest way is to use the Template display name.


  5. Iris says:

    Ok, thank u! But I think the problem occurred one step later when using the projection in ‘set-scsmobjecttemplate’ the variable SRProj is null, so it doesn’t find a matching service request in the projection. The template I want to apply is found like u could see in the text file …;(

    • Just a quick note.

      Did you remember the $ at the end of the Projection line?

      Is it needed as a “stop” so it does not look for sub components.



      Sent from Windows Mail using my Microsoft Surface

  6. Iris says:

    yes, i used it…;(

Leave a Reply

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

You are commenting using your 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