Home Service Manager

Is there a way to get the members of group?

RomualdtRomualdt Member IT Monkey ✭
I would like to use SCSM group membership to skip a step in a list of activities.  If the person submitting the change request is a in a newly created group "ERP Change Approver" then we don't need to get approval from the line manager.

Best Answer

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    edited August 2018 Answer ✓
    Here's how to get an SCSM Group seen in the Library node and its members:

    $scsmGroupName = "my custom scsm group name"
    $scsmGroup = Get-SCGroup -DisplayName $scsmGroupName
    $scsmGroup.members | select-object DisplayName

Answers

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    I think the best way to accomplish this is with a Runbook of the Microsoft SCO or SMA nature. Alternatively, you could use the Cireson PowerShell Activity.

    In any of these three cases, the runbook activity would be placed before the RA to evaluate the condition and then skip/do nothing.
  • RomualdtRomualdt Member IT Monkey ✭
    PowerShell sound like the option I am looking for but can't seem to find the group object.
    I can get the group but not the members.

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    edited August 2018
    So there a few things to be aware of around RA, users, and groups in SCSM.

    1. SCSM syncs users and groups
    2. SCSM does not maintain the relationship between a group and its users
    3. RAs are tricky in that you have to get the RA, then the Reviewer(s), and then from that a User. So that's a few different items to swing across. RA -> Reviewers -> Reviewer -> User.

    Since you can't get this relationship data in SCSM, your best bet is to live query Active Directory with the Active Directory PS module. If you're wondering how to get started, I think the following should get you started in the right direction. Apologies on the formatting.

    ####get classes
    $raClass = get-scsmclass -name "System.WorkItem.Activity.ReviewActivity$"
    $reviewerClass = get-scsmclass -name "System.Reviewer$"
    $adGroupClass = get-scsmclass -name "Microsoft.AD.Group$"
    $adUserClass = get-scsmclass -name "Microsoft.AD.User$"
    $smaClass = get-scsmclass -name "System.WorkItem.Activity.SMARunbookActivity$"
    $crClass = Get-SCSMClass -Name "System.WorkItem.ChangeRequest$"
    $containsActRelClass = Get-SCSMRelationshipClass -name "System.WorkItemContainsActivity$"

    ####get relationship classes
    $raHasReviewerRelClass = get-scsmrelationshipclass -name "System.ReviewActivityHasReviewer$"
    $reviewerIsUserRelClass = get-scsmrelationshipclass -name "System.ReviewerIsUser$"

    ####get the change request
    $changeRequest = get-scsmobject -class $crClass -filter "Name -eq 'CR1234'"

    ####get all Review Activites
    $reviewActivities = Get-SCSMRelatedObject -SMObject $changeRequest -Relationship $containsActRelClass | where-object {$_.ClassName -eq "System.WorkItem.Activity.ReviewActivity"}

    ####loop through each Review Activity
    foreach ($reviewActivity in $reviewActivities)
    {
    ####get all the reviewers in the review activity
    $reviewers = get-scsmrelatedobject -SMObject $reviewActivity

    foreach ($reviewer in $reviewers)
    {
    ####determine if the reviewer is an Active Directory Group
    $reviewerToEvaluate = get-scsmrelatedobject -SMObject $reviewer -relationship $reviewerIsUserRelClass
    if ($reviewerToEvaluate.IsInstanceOf($adGroupClass) -eq $true)
    {
    ####get the group's members from Active Directory
    $reviewGroup = get-adgroup $reviewerToEvaluate.DistinguishedName
    $reviewGroupMembers = get-adgroupmember $reviewerToEvaluate.DistinguishedName
    }
    }
    }

  • RomualdtRomualdt Member IT Monkey ✭
    Thanks for the quick response:
    So there is no way to use the "Groups" in the service manger Library, I have to use an AD group?
  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    edited August 2018
    OH those groups...
  • RomualdtRomualdt Member IT Monkey ✭
    Yeah if I can get the members I can figure out how to skip the activity 
  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    edited August 2018 Answer ✓
    Here's how to get an SCSM Group seen in the Library node and its members:

    $scsmGroupName = "my custom scsm group name"
    $scsmGroup = Get-SCGroup -DisplayName $scsmGroupName
    $scsmGroup.members | select-object DisplayName

Sign In or Register to comment.