IT Monkey:   Click Here to Help Me Build the Agenda for Upcoming Cireson Webinars!

how to randomly assign tickets to analysts of one support group?

Silas_SulserSilas_Sulser Customer Advanced IT Monkey ✭✭✭
I know thats a weird usecase, but one of our support group leaders came up with that specific solution request.
They have the policy that, all unassigned ticket of that pool need to be assigned before lunch and before leaving in the evening.
Unofrutnately nobody feels responsible for assigning these tickets.
Would it be possible to randomly assign these tickets within this specific support group?
How do you handle resistant ticket assignment?

Best Answer

  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited December 2017 Accepted Answer
    It isn't that weird. :)

    So yes - totally doable with PowerShell runbooking. I just punched this up and isn't done by any means, but I think it's at least the basis for starting this since there are a lot of different ways you could get the users rather punching each of them in assuming its a large support tier (i.e. Get-ADGroupMember)

    #declare constants
    $mgmtServer = "localhost"
    $today = get-date
    $irClass = get-scsmclass -name "system.workitem.incident$" -ComputerName $mgmtServer
    $userClass = get-scsmclass -name "System.domain.user$" -ComputerName $mgmtServer
    $activeEnum = Get-SCSMEnumeration -name "IncidentStatusEnum.Active$" -ComputerName $mgmtServer
    $assignedToUserRelClass = Get-SCSMRelationshipClass -name "System.WorkItemAssignedToUser$" -ComputerName $mgmtServer
    
    #need to get the User objects that you'll eventually randomly assign these Incidents
    $user1 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAMEHERE'" -ComputerName $mgmtServer
    $user2 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAMEHERE'" -ComputerName $mgmtServer
    $user3 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAMEHERE'" -ComputerName $mgmtServer
    $usersToAssign = @($user1, $user2, $user3)
    
    #get all the Incidents created today
    $incidents = get-scsmobject -class $irClass -Filter "CreatedDate -gt $($today.ToShortDateString())" -ComputerName $mgmtServer
    
    #loop through the Incidents and see which are unassigned
    foreach ($incident in $incidents)
    {
        $assignedToUser = Get-SCSMRelatedObject -SMObject $incident -Relationship $assignedUserRelClass -ComputerName $mgmtServer
     
        #Randomly pick one of the users and assign them to the unassigned Incident
        if ($assignedToUser.Displayname -eq $null) 
        {
            $userToAssign = $usersToAssign | get-random
            New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $userToAssign -ComputerName $mgmtServer
        } 
    }

Answers

  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited December 2017 Accepted Answer
    It isn't that weird. :)

    So yes - totally doable with PowerShell runbooking. I just punched this up and isn't done by any means, but I think it's at least the basis for starting this since there are a lot of different ways you could get the users rather punching each of them in assuming its a large support tier (i.e. Get-ADGroupMember)

    #declare constants
    $mgmtServer = "localhost"
    $today = get-date
    $irClass = get-scsmclass -name "system.workitem.incident$" -ComputerName $mgmtServer
    $userClass = get-scsmclass -name "System.domain.user$" -ComputerName $mgmtServer
    $activeEnum = Get-SCSMEnumeration -name "IncidentStatusEnum.Active$" -ComputerName $mgmtServer
    $assignedToUserRelClass = Get-SCSMRelationshipClass -name "System.WorkItemAssignedToUser$" -ComputerName $mgmtServer
    
    #need to get the User objects that you'll eventually randomly assign these Incidents
    $user1 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAMEHERE'" -ComputerName $mgmtServer
    $user2 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAMEHERE'" -ComputerName $mgmtServer
    $user3 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAMEHERE'" -ComputerName $mgmtServer
    $usersToAssign = @($user1, $user2, $user3)
    
    #get all the Incidents created today
    $incidents = get-scsmobject -class $irClass -Filter "CreatedDate -gt $($today.ToShortDateString())" -ComputerName $mgmtServer
    
    #loop through the Incidents and see which are unassigned
    foreach ($incident in $incidents)
    {
        $assignedToUser = Get-SCSMRelatedObject -SMObject $incident -Relationship $assignedUserRelClass -ComputerName $mgmtServer
     
        #Randomly pick one of the users and assign them to the unassigned Incident
        if ($assignedToUser.Displayname -eq $null) 
        {
            $userToAssign = $usersToAssign | get-random
            New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $userToAssign -ComputerName $mgmtServer
        } 
    }
  • Brian_WiestBrian_Wiest Customer Super IT Monkey ✭✭✭✭✭
    We are currently working on the same "Use Case". We are calling it SCSMWire (Work item reassignment engine) 
    In our old system we had a tool custom built that would round robin incoming emails based on analyst availability. 
    We are building a similar engine for SCSM. 

    Parts 
    -SQL Database for tracking analyst availability, schedule, last assignment
    -Code checks their logon via Skype Presence to make sure they are logged into the network in relation to their availability 
    -Code that checks for a specific support group and unassigned. Once it finds one it checks the availability and Skype and then assigns to that analyst
    -Webpage for the support desk lead to manage the analyst availability.

    Currently we are little stuck on Skype but getting there. 

    While @Adam_Dzyacky provides awesome code to meet the tech needs. We have found that you can get into a bind of Analysts being off for Vac/Sick getting work and not one taking ownership. 
  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited December 2017
    something something Exchange Out of Office check something something @Brian_Wiest? But agreed, this is a very technical solution to a somewhat management style problem.

    And Round robin on incoming emails...something about that sounds so familiar.

    :)
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    I think a universal solution for this would be killer.  I think availability management is the hardest part since everyone uses a different approach.  Exchange presence is good, but not great and can be manipulated by people avoiding assignment.  @Brian_Wiest I like your idea of a webpage to manage the availability manually.  I used to do something similar but it was just a list in a text file!
  • Silas_SulserSilas_Sulser Customer Advanced IT Monkey ✭✭✭
    @Adam_Dzyacky Many thanks for your script, youre a legend!! :)
    Im gonna check that out soon.
    It's interesting to see, that we are not alone with this problem.

    @Brian_Wiest I'm always impressed about your SQL skills, I guess there is nothing you can't do with SQL :)





  • Steven_PetersonSteven_Peterson Customer IT Monkey ✭
    Thanks for this great write up! Found it very helpful creating a similar solution within my own environment. Using your script I added some additional functionality that may be useful to others.
    • Odd/Even Method - Determines if ticket ID is odd/even and assigns to the appropriate technician; static
    • Traditional Round Robin - Determines Random then begins assigning tickets round-robin to appropriate technicians; static
    • Logging Routine
    Our helpdesk is rather small so I was able to get away with static's for the users, but could be tweaked to make more dynamic for larger teams.

    Import-Module 'C:\Program Files\Microsoft System Center 2012 R2\Service Manager\PowerShell\System.Center.Service.Manager.psd1' -force
    import-module smlets

    #logging function
    $Logfile = "\\xxx\logs\$(gc env:computername).log"

    Function LogWrite
    {
       Param ([string]$logstring)

       Add-content $Logfile -value $logstring
    }

    #declare constants
    $mgmtServer = "SERVERNAME"
    $today = get-date
    $irClass = get-scsmclass -name "system.workitem.incident" -ComputerName $mgmtServer
    $userClass = get-scsmclass -name "System.domain.user" -ComputerName $mgmtServer
    $activeEnum = Get-SCSMEnumeration -name "IncidentStatusEnum.Active" -ComputerName $mgmtServer
    $assignedToUserRelClass = Get-SCSMRelationshipClass -name "System.WorkItemAssignedToUser" -ComputerName $mgmtServer
    $body = @()

    #need to get the User objects that you'll eventually randomly assign these Incidents
    $user1 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAME'" -ComputerName $mgmtServer
    $user2 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAME'" -ComputerName $mgmtServer
    $usersToAssign = @($user1, $user2)
    $userToAssign = $usersToAssign | get-random

    #get all the Incidents created today
    $incidents = get-scsmobject -class $irClass -Filter "CreatedDate -gt $($today.ToShortDateString())" -ComputerName $mgmtServer

    #loop through the Incidents and see which are unassigned
    foreach ($incident in $incidents)
    {
        $assignedToUser = Get-SCSMRelatedObject -SMObject $incident -Relationship $assignedUserRelClass -ComputerName $mgmtServer
        
        $ID = $incident.Id #give me another variable to work with
        $Result = $ID.substring(2) % 2 #strip the IR and determine if ID odd/even

        #Define Odd/Even and assign them to the unassigned Incident
     <#--
        if ($result -eq 0 -and $incident.TierQueue.DisplayName -eq 'Service Desk' ) 
        { 
                LogWrite "E - $ID assigned to $user1 - $today"
                New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $user1 -ComputerName $mgmtServer -Bulk
        }

        if ($result -eq 1 -and $incident.TierQueue.DisplayName -eq 'Service Desk')
        {
                LogWrite "O - $ID assigned to $user2 - $today"
                New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $user2 -ComputerName $mgmtServer -Bulk
        } 
    --#>

    <#-- 
        #Randomly pick one of the users and assign them to the unassigned Incident
        if ($incident.FirstAssignedDate -eq $null -and $incident.TierQueue.DisplayName -eq 'Service Desk') 
        {
            $userToAssign = $usersToAssign | get-random
            #New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $userToAssign -ComputerName $mgmtServer
            LogWrite "$ID assigned to $userToAssign"
         }
    --#>

        #Round Robin Ticket Assignment
        if ($incident.FirstAssignedDate -eq $null -and $incident.TierQueue.DisplayName -eq 'Service Desk')
        {
        New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $userToAssign -ComputerName $mgmtServer -Bulk
        $LastAssignedUser = $userToAssign
        LogWrite "$ID assigned to $LastAssignedUser at $today"
        
        if ($lastassigneduser -eq $user1)
        {
            $userToAssign = $user2            
        }
        
        else 
        { 
            $userToAssign = $user1 
        }
         
         
        }

  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    Nice work @Steven_Peterson! If you're up for it, I'd for one welcome your round robin addon into the SMLets Exchange Connector here on the community and over at Github.
Sign In or Register to comment.