Home Analyst Portal

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 Product Owner Contributor Monkey ✭✭✭✭✭
    edited December 2017 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 Product Owner Contributor Monkey ✭✭✭✭✭
    edited December 2017 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 Product Owner 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.

    <div>Import-Module 'C:\Program Files\Microsoft System Center 2012 R2\Service Manager\PowerShell\System.Center.Service.Manager.psd1' -force</div><div>import-module smlets</div><div><br></div><div>#logging function</div><div>$Logfile = "\\xxx\logs\$(gc env:computername).log"</div><div><br></div><div>Function LogWrite</div><div>{</div><div>&nbsp; &nbsp;Param ([string]$logstring)</div><div><br></div><div>&nbsp; &nbsp;Add-content $Logfile -value $logstring</div><div>}</div><div><br></div><div>#declare constants</div><div>$mgmtServer = "SERVERNAME"</div><div>$today = get-date</div><div>$irClass = get-scsmclass -name "system.workitem.incident" -ComputerName $mgmtServer</div><div>$userClass = get-scsmclass -name "System.domain.user" -ComputerName $mgmtServer</div><div>$activeEnum = Get-SCSMEnumeration -name "IncidentStatusEnum.Active" -ComputerName $mgmtServer</div><div>$assignedToUserRelClass = Get-SCSMRelationshipClass -name "System.WorkItemAssignedToUser" -ComputerName $mgmtServer</div><div>$body = @()</div><div><br></div><div>#need to get the User objects that you'll eventually randomly assign these Incidents</div><div>$user1 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAME'" -ComputerName $mgmtServer</div><div>$user2 = get-scsmobject -class $userClass -Filter "username -eq 'USERNAME'" -ComputerName $mgmtServer</div><div>$usersToAssign = @($user1, $user2)</div><div>$userToAssign = $usersToAssign | get-random</div><div><br></div><div>#get all the Incidents created today</div><div>$incidents = get-scsmobject -class $irClass -Filter "CreatedDate -gt $($today.ToShortDateString())" -ComputerName $mgmtServer</div><div><br></div><div>#loop through the Incidents and see which are unassigned</div><div>foreach ($incident in $incidents)</div><div>{</div><div>&nbsp; &nbsp; $assignedToUser = Get-SCSMRelatedObject -SMObject $incident -Relationship $assignedUserRelClass -ComputerName $mgmtServer</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; $ID = $incident.Id #give me another variable to work with</div><div>&nbsp; &nbsp; $Result = $ID.substring(2) % 2 #strip the IR and determine if ID odd/even</div><div><br></div><div>&nbsp; &nbsp; #Define Odd/Even and assign them to the unassigned Incident</div><div>&nbsp;<#--</div><div>&nbsp; &nbsp; if ($result -eq 0 -and $incident.TierQueue.DisplayName -eq 'Service Desk' )&nbsp;</div><div>&nbsp; &nbsp; {&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LogWrite "E - $ID assigned to $user1 - $today"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $user1 -ComputerName $mgmtServer -Bulk</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; if ($result -eq 1 -and $incident.TierQueue.DisplayName -eq 'Service Desk')</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LogWrite "O - $ID assigned to $user2 - $today"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $user2 -ComputerName $mgmtServer -Bulk</div><div>&nbsp; &nbsp; }&nbsp;</div><div>--#></div><div><br></div><div><#--&nbsp;</div><div>&nbsp; &nbsp; #Randomly pick one of the users and assign them to the unassigned Incident</div><div>&nbsp; &nbsp; if ($incident.FirstAssignedDate -eq $null -and $incident.TierQueue.DisplayName -eq 'Service Desk')&nbsp;</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; $userToAssign = $usersToAssign | get-random</div><div>&nbsp; &nbsp; &nbsp; &nbsp; #New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $userToAssign -ComputerName $mgmtServer</div><div>&nbsp; &nbsp; &nbsp; &nbsp; LogWrite "$ID assigned to $userToAssign"</div><div>&nbsp; &nbsp; &nbsp;}</div><div>--#></div><div><br></div><div>&nbsp; &nbsp; #Round Robin Ticket Assignment</div><div>&nbsp; &nbsp; if ($incident.FirstAssignedDate -eq $null -and $incident.TierQueue.DisplayName -eq 'Service Desk')</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; New-SCSMRelationshipObject -Source $incident -Relationship $assignedToUserRelClass -Target $userToAssign -ComputerName $mgmtServer -Bulk</div><div>&nbsp; &nbsp; $LastAssignedUser = $userToAssign</div><div>&nbsp; &nbsp; LogWrite "$ID assigned to $LastAssignedUser at $today"</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; if ($lastassigneduser -eq $user1)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; $userToAssign = $user2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; else&nbsp;</div><div>&nbsp; &nbsp; {&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; $userToAssign = $user1&nbsp;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; }</div><div>}&nbsp;</div>

  • Adam_DzyackyAdam_Dzyacky Product Owner 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.