Change Assigned user with SMlets

alfie thomas 86 Reputation points
2021-05-26T10:43:05.137+00:00

Hi guys,

Using a script to change a support group depending on the input of an Incident question.

I want to do the similar but change the affected user on the ticket. What I am lost with is what enumeration to user for Assigned User. I know the script is wrong but I don't understand how to find the things I am looking for to update it.

This is my script for changing Support group but trying to change it:

Import-Module SMLets
$smDefaultComputer = "scssm04"
$irID = "IR"

$assignedTo1 = "USER1"
$assignedTo2 = "USER2"
$irClassification = "EXAMPLE"

$classIncident = Get-SCSMClass -Name System.WorkItem.Incident$

$irObj = Get-SCSMObject -Class $classIncident -Filter "ID -eq $irID"
$irDescription = $irObj.Description
$irObjClassification = $irObj.Classification.DisplayName

if ($irObjClassification -eq $irClassification) {
if ($irDescription -match "What Type Of Request User Allocation") {
Set-SCSMObject -SMObject $irObj -Property "TierQueue" -Value $assignedTo1
$result = "IR is classification $irClassification and SupportGroup $assignedTo1"
}
else {
if ($irDescription -match "Which Bank Account Is Affected Payment Query") {
$newSupportGroup = "$enumSupportGroup1"
Set-SCSMObject -SMObject $irObj -Property TierQueue -Value $assignedTo2
$result = "IR is classification $irClassification and SupportGroup $assignedTo2"
}
else {
$result = "IR is classification $irClassification but no condition met"
}
}
}
else {
$result = "IR is not classification $irClassification"
}
$result

Thanks in advance,
Alfie.

Service Manager
Service Manager
A family of System Center products for managing incidents and problems.
205 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,271 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 91,211 Reputation points MVP
    2021-05-26T12:55:32.863+00:00

    Hi @alfie thomas ,

    The Affected User isn't an enumeration in SCSM. Test The Affected User, same like the Assigned To User, is a relationship between Incident class (Work Item Classe) and the User class in SCSM.

    Maybe this is helpful (line 22 contains the relationship class Work Item to Affected User):

    https://github.com/abaumgarten42/SCSM_Useful_PSscripts/blob/main/Get-IncidentDetails.ps1

    And in this script you can see how to create a relationship in SCSM (instead of Primary User relationship you have to use the Affected User relationship)

    https://github.com/abaumgarten42/SCSM_Useful_PSscripts/blob/main/Set-PrimaryAndAssignedUser.ps1

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


  2. Andreas Baumgarten 91,211 Reputation points MVP
    2021-05-27T15:24:14.16+00:00

    Hi @alfie thomas ,

    the Incident Priority is a property of the Incident class, not a relationship and not an enumeration (if I remember right).
    The Incident Priority is automatically "calculated" by Incident Urgency and Incident Impact.
    https://learn.microsoft.com/en-us/system-center/scsm/incident-mgt?view=sc-sm-2019#configure-incident-settings

    You can't directly change the Priority. If you want to get a different Priority you have to change the Impact and/or the Urgency of the Incident.

    Changing Impact or Urgency is possible via PowerShell or SCSM Update Object activity in Orchestrator. Both properties are enumerations.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments