Posts Tagged ‘workflow’

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.

Script

#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 = $SR.name
$SRTitle = $SR.Title
Write-Host $SRName " - " $SRTitle
#$SRName

# 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)

Just recently I was looking for a way to notify users about Inactive incidents as I have some departments that tend to ignore their work items and an e-mail about their “untouched” incidents seems to motivate them. So after some searching I found this script from Andreas Baumgarten

Please note : I only modified this script to extend its use to other Statuses to be monitored. All credit for the script goes entirely to Andreas Baumgarten

Code is below

# Configure Last Modified Days Before
$ModifiedBefore = 3

#Configure Incident Status
$IncidentStatus = 'Active'

# Configure your mail server, the recipient and the sender of the mail
# $smtphost=”mailserver.yourdomain.local”
# $from=”mail@yourdomain.local”

$smtphost=”Mailserver.demo.local”
$from=”Helpdesk@demo.local”

# Send-Mail function
function Send-Mail
{
Param($From,$To,$Subject,$Body)
$smtp = new-object system.net.mail.smtpClient($smtphost)
$mail = new-object System.Net.Mail.MailMessage
$mail.from= $From
$mail.to.add($To)
$mail.subject= $Subject
$mail.body= $Body
$mail.isbodyhtml=$true
$smtp.send($Mail)
}

# Some other variables
$BeforeDate = (Get-Date).AddDays(-$ModifiedBefore).ToString("MM/dd/yyy HH:mm:ss")
$Status = Get-SCSMEnumeration IncidentStatusEnum.$IncidentStatus$
$AssignedUserObjectRelClass = Get-SCSMRelationshipClass System.WorkItemAssignedToUser
$IncidentClass = Get-SCSMClass -name System.WorkItem.Incident$

#Get all incidents last modfied xy days before
$Incidents= @(Get-SCSMObject -Class $IncidentClass | Where {($_.Status -eq $Status -AND $_.LastModified -lt $BeforeDate)})

If ($Incidents.count -gt 0)
{

#Get all assigned incidents from list
foreach ($Incident in $Incidents)
{
# Get AssignedToUser
$AssignedUser = Get-SCSMRelatedObject -SMObject $Incident -Relationship $AssignedUserObjectRelClass

# Incidents AssignedTo is not NULL
If ($AssignedUser.Displayname -ne $NULL)
{
#Get email adress of AssignedToUser
$EndPoint = Get-SCSMRelatedObject -SMObject $assignedUser -Relationship $UserPref|?{$_.ChannelName -like '*SMTP'}
$Sendto = $Endpoint.Targetaddress

#Create Output
$Output = 'This Incident has been inactive for ' + $ModifiedBefore + ' day(s): <br>' + $Incident.ID + ' - ' + $Incident.Title + ' - Last Modified: ' + $Incident.Lastmodified
$Output
#Send email
$To = $Sendto
$Subject = 'Inactive incident for ' + $ModifiedBefore + ' day(s): ' + $Incident.Id + ' ' + $Incident.Title
$Body = $Output
Send-Mail $From $to $Subject $Body
}
}
}

Remove-Module SMlets -force 

Okay, so now that the code is there, I had to make some modifications in order for the Code to work with “NON-DEFAULT” Incident Statuses. I have created some additional Pending statuses.

The key line in this code is

Configure Incident Status
$IncidentStatus = 'Active'

and

$Status = Get-SCSMEnumeration IncidentStatusEnum.$IncidentStatus$

This allows you specify the Status. However if you use additional “NON-DEFAULT” statuses, this would need to be modified to suit your needs. You would need to modify the line of code to read as follows.

$IncidentStatus = 'Enum.847741a452db4d529741005ea73aead8'

and

$Status = Get-SCSMEnumeration $IncidentStatus$

You will notice the change of $IncidentStatus to a “ENUM” Value as this is a “NON-DEFAULT” value, you need to use the ENUM value. This can be gotten by using the following with SMLets

Get-SCSMEnumeration | Format-list | out-file

Below, is a screenshot to help illustrate this further.

EnumSearch1

Once you have a list of all your Enumerations, then search for the required value, for example “Pending – Waiting for 3rd Party”, you will then see a “Name” value and that whole string is your ENUM value.

You will also see that the $Status line has been changed to cater for the ENUM value.

Modify to meet your needs and create a workflow if you want to.

Follow me.

facebook-small322252222twitter-small322252222

MCC11_Logo_Horizontal_2-color_thumb_