question

alfiethomas-8724 avatar image
0 Votes"
alfiethomas-8724 asked XinGuo-MSFT edited

Can you update SM change request Assigned To to match created by with SMLETs?

Hi guys,

Not great at Runbooks or PowerShell but having trouble working with Change requests in either.



Has anyone got or seen a working example of either in PowerShell or in a runbook where you could have it update the Assigned To field to match the Created By field?



We are looking at standard changes and don't want to have to make people assign themselves to the change.

TIA.

windows-serverwindows-server-powershellmsc-service-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hi there,

Found this PowerShell script try to execute this and see if this can help you in getting your requirements fulfilled.

$incident = "IR3406"
$username = "Lopez"
$domain = "LAB"
Import-Module SMLets
$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 $username}
$r = Get-SCSMRelationshipClass System.WorkItemAssignedToUser$
Get-SCSMRelationshipObject -Relationship $r | ?{$_.SourceObject -eq $i} | Remove-SCSMRelationshipObject
$n = New-SCSMRelationshipObject -Relationship $r -Source $i -Target $u -NoCommit
$n.Commit()
Remove-Module SMLets

You can read more about this from the below article

Change Assigned user with SMlets https://docs.microsoft.com/en-us/answers/questions/410315/change-assigned-user-with-smlets.html

SCSM how to change assigned to of an incident from PowerShell https://social.technet.microsoft.com/Forums/ie/en-US/cc9ce2db-26a5-4a06-b3cb-490872ac43c5/scsm-how-to-change-assigned-to-of-an-incident-from-powershell?forum=systemcenterservicemanager



--If the reply is helpful, please Upvote and Accept it as an answer–

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.