PowerShell Activity - SR AffectedUser
Best Answer
-
Brian_Wiest Customer Super IT Monkey ✭✭✭✭✭Here is something to get you started
This script grabs the created by user of a CR and creates a relationship for assigned to user.
Just modify the class to SR and perform the function you would like to accomplish.
the Param ID is "Parent Base ID"Param([guid]$id)Import-Module SMLets$crcl = get-scsmclass -name system.workitem.changerequest$$cr = get-scsmobject -class $crcl -filter "id -eq '$id'"$createdByRel = Get-SCSMRelationshipClass -name system.workitemcreatedbyuser$$createdyByUser = get-scsmrelatedobject -SMObject $cr -Relationship $createdByRel$assignedByRel = get-scsmrelationshipclass -name system.workitemassignedtouser$New-SCSMRelationshipObject -Relationship $assignedByRel -source $cr -target $createdyByUser -bulkRemove-Module SMlets6
Answers
This script grabs the created by user of a CR and creates a relationship for assigned to user.
Just modify the class to SR and perform the function you would like to accomplish.
the Param ID is "Parent Base ID"
Alexander please try to use the ID of the used SCSM Class instead of the name:
$SCSMclassSR = Get-SCSMClass -Name "System.WorkItem.ServiceRequest$" # Error: Cannot bind argument to parameter 'Class' because it is null.
$SCSMclassSR = Get-SCSMClass -ID "04B69835-6343-4DE2-4B19-6BE08C612989" # Working
thank you. I used the ID instead of the name and now it works.