Skip to main content

Round Robin Assignment in Service Manager- Part 4: Get Next User Script

Author by Christopher Mank

In this fourth and last part, I am going to show how the Get Next User Powershell script works that determines who the next user is to be assigned to the Incident. 

Below is a screenshot of the script. We'll walk through each section so you understand exactly what it's doing and how it works. 


Blue Section

The first thing script does is import a few needed modules. For this script to function, you will need to install the Active Directory module for Windows Powershell feature and the SMLets. A link to the SMLets install can be found here. 


Yellow Section

In this code block, we setup some variables that will be used in the script later on. To better display the script, I copied it into the PowerShell ISE. Line #s 4-5 are actually published variables from our Runbook. The Distinguished Names of the AD Group and Last Assigned User are passed in. 

The most notable line to point out is Line #13. Here we are getting all of the members in the AD group and assigning them to the $arr_Members array. You will notice that the results are piped to the "Sort-Object name" command. This is extremely important. The order of the objects in the array dictates the order of the round robin assignment. As you can see, I am just sorting by name in ascending order. If you wish to have the AD group sorted in a different way, and thus the round robin, this would be the section of code you can modify to sort the array in the order you desire. 


Green Section

In this code block, we loop through each member of the $arr_Members array to determine if the members are available for assignment. To do this, we take the Distinuished Name of each AD member and use it to look up the user object in SCSM. Once we have the object, we add the user's Distiniguished Name to a second array IF the user is both Round Robin Enabled and not Out of Office. If the user object does not meet both requirements, it is not added to the $arr_Users array. 


Red Section

In this code block, we loop through each member of the $arr_Users array to find the matching user who was last assigned to an Incident. This last assigned user is passed into the script by the Runbook. Once we find the last assigned user in the array, we set the $bln_NextUserflag. Then, we loop through the array one more time and assign that user to the $str_NextUser variable. This is the next user in line for the round robin assignment. 


Pink Section 

In this code block, we check to make sure that we've found a valid user to assign to the Incident. If we did, we set the $str_NextUser variable to the Distinguished Name of the user. If the script could not be determine a next user, that variable will be blank.

Below you will find some of the scenarios that were tested against the script and what the outcome is for each scenario. 

  • User is on vacation- User is skipped from the rotation.
  • User is not Round Robin Enabled- User is skipped from the rotation.
  • User is in AD but not in SCSM- User is skipped from the rotation. 
  • No users are in the AD Group- No user is assigned to the Incident 
  • Last Assigned User is no longer in the AD Group- The first user in the rotation is assigned to the Incident and the rotation continues as normal. 
  • Last Assigned User is no longer available (on vacation, Out of Office, etc.)- The first user in the rotation is assigned to the Incident and the rotation continue as normal. 


That's all there is to it. I really hope this blog series has helped those out looking to setup Round Robin in their Service Manager environment. If you have any questions or thoughts, feel free to drop a comment below. See you next time!

Stay tuned! Part 1: IntroductionPart 2: SCSM SetupPart 3: Orchestrator SetupPart 4: Get Next User Script (this post)

Until the Whole World Hears,



Christopher Mank

Systems Architect

Tags in this Article