IT Knowledge Base

Technical Repository

HowTo: How to change the AssignedTo username for Incidents in System Center Service Manager 2012 R2

$Incident = "IR Number"
$CurrentUsername = "This is the username that is currently in the AssignedTo field"
$NewUsername = “The new username”
$Domain = "NETBIOS Domain Name"

$i = Get-SCSMObject (Get-SCSMClass System.WorkItem.Incident$) -Filter "Id -eq $Incident "
$u = Get-SCSMObject (Get-SCSMClass System.Domain.User$) | ?{$_.Domain -eq $Domain -and $_.Username -eq $CurrentUsername }
$r = Get-SCSMRelationshipClass System.WorkItemAssignedToUser 
Get-SCSMRelationshipObject -Relationship $r | ?{$_.SourceObject -eq $i} | Remove-SCSMRelationshipObject
$nu = Get-SCSMObject (Get-SCSMClass System.Domain.User$) | ?{$_.Domain -eq $Domain -and $_.Username -eq $NewUsername }
$n = New-SCSMRelationshipObject -Relationship $r -Source $i -Target $nu –NoCommit
$n.commit()



Leave a Reply