Runbook to apply affected user from String

John_BeasleyJohn_Beasley Customer IT Monkey ✭
Ok, I have a Runbook that basically runs a Powershell script to read from a table of another system. All data is retrieved fine. I then have it create a SCSM Service Request. I update the properties of the request and the description. I am trying to take stringproperty12 which is an domain/user name and add that to the Affected User on the Service Request. Any Help would be greatly appreciated. 

Respectfully, 

John

Answers

  • Adam_DzyackyAdam_Dzyacky Customer Contributor Monkey ✭✭✭✭✭
    edited January 16
    The general idea of what you'll need to do is first you'll need the User class, run a search against that class with the string you have, and then set that user as the Affected User on your SR. In order to complete this, you also need the SR/Work Item object to complete the relationship between the user and said work item.

    $domainUserClass = get-scsmclass -name "System.Domain.User$"
    $affectedUserRelClass = get-scsmrelationshipclass -name "System.WorkItemAffectedUser$"
    $affectedUser = Get-SCSMObject -class $domainUserClass -filter "Username -eq 'YOURSTRING'"
    New-SCSMRelationshipObject -Relationship $affectedUserRelClass -Source $newWorkItem -Target $affectedUser -Bulk


Sign In or Register to comment.