Service Manager: Create a “Reviewers” object by using PowerShell #SCSM

You might be aware that Service Manager allows you to use Review Activities (RA) in a SR or CR to approve requests. RAs can be easily added to the process in the SCSM console. After adding the RA, you must add AD User CI that will be used to approve the request. If you take a look at the backend things are a little more complex, especially when you want to add approvers using a PowerShell script.

My fellow MVP colleague Anders Asp already blogged about this and how you can handle this when using Orchestrator. He explains that a AD User (or Group) is not directly added to a Review Activity, but another object is used to connect the review Activity and the AD User Object. This allows to configure some additional attributes. Something like this:

  • Review Activity —[ReviewActivityHasReviewer]—> Reviewer
  • Reviewer —[ReviewerIsUser]—> AD User

When you hit “Add” on a Review Activity you will not recognize that another object of class “Reviewer” is created. But it’s there:



In the GUI you cannot really see that another object has been created. But you can using PowerShell. I will first get one of the Review Activities out of the system.


Now lets get the related reviewer object.


The RA will have multiple relationships to other objects. You could of course narrow down the results by using a filter that only displays relationship objects with a specific relationship id (in this case the id of the relationship class “System.ReviewActivityHasReviewer”.


As you can see, my RA has a relationship to a Reviewers Object. You can now save the Reviewer in an object and go through the next relationshipto the AD User CI.


Got it. Now comes the tricky part. Both relationships are of a different type.

  • ReviewerIsUser –> Reference Relationship
  • ReviewActivityHasReviewer –> Membership Relationship


The Reference Relationship is easy to handle. Both objects can exist alone, if needed they can be related. If the relationship is deleted again, the objects remain in the CMDB.

The Membership Relationship is a bit harder to manage. The target object get created and in the same transaction needs to be related to the source object. If the source object get deleted, the target object will also be deleted.

What does that mean now if you want to set a reviewer in a RA by using a PowerShell script? I means that you must go throug a 2-step process.

  • Step 1: Create a new Reviewer object and at the same time relate it to the RA
  • Step 2: Add a relationship from the newly created Reviewer object to a AD User CI

I will only cover step 2 because step 1 is very simple and you will find tons of examples how to deal with this. The script for step 1 however is tricky because of the 2-things-at-the-same-time approach and could look something like this.

$smdefaultcomputer = “sm01”

#RA to which a new approver should be added

$raid = “RA1021”

import-module smlets

#Get existing RA

$raobj = get-scsmobject -class (get-scsmclass System.WorkItem.Activity.ReviewActivity$) -filter “Id = $raid”

#Create a new projection
#Start with the Source Class of the Relationship = Review Activity
#Add details of the related Object, the term “Reviewer” is the alias of the review activity type projection that consists of the seed class (Review Activity””) and 1 component (Reviewer, Alias=reviewer). I only set the Id, of course you can set additional properties if needed

$projection = @{__CLASS = “System.WorkItem.Activity.ReviewActivity”;

                               __SEED = $raobj;

                                               Reviewer = @{__CLASS = “System.Reviewer”;__OBJECT = @{“ID”=”{0}”}}


#Create the new projection – the reveiwers object and link it to the RA at the same time

new-scsmobjectprojection -type System.WorkItem.Activity.ReviewActivityViewProjection$ -projection $projection

After running the script, the RA will look something like this.



In the next step you would just create a new relationship from the Reviewers object to a AD User CI, set additional properties if needed and you are done!


About Marcel Zehner

Microsoft Azure MVP
This entry was posted in SCSM and tagged , , , , , , . Bookmark the permalink.

4 Responses to Service Manager: Create a “Reviewers” object by using PowerShell #SCSM

  1. Lisa Bell says:

    Hello, I am new to a project where SCSM is being rolled out. I have found or been given some issues when they went live and now trying to help find the best way to resolve the needs.
    One need is to auto send an email out once the request is closed to ONLY the requester and not the entire group that was impacted. Is this possible in SCSM or is it a limitation? this is one of a few “higher” priorities.
    Thank you for any assistance.

    • Marcel Zehner says:


      Setup a workflow should work that triggers when the SR status is changed from “not = closed” to “= closed”. Then send out an email to the affected user of the SR by using a notification template.


  2. Simon says:

    Hi Marcel,

    I already have Orchestrator configured to dynamically add a reviewer out of AD to a service request template that has only 1 review activity.

    We have a couple of service requests however where there are two levels of review, so I have 2 review activities in the template. When one activity is completed I would like it to then move onto the second one.

    The Orchestrator job is now failing because it’s only expecting one activity. How can I determine the order of the activities so I can assign one user to the first activity, and a different user to the second activity? Filters don’t seem to have enough logic.

    I have the Parent SR GUID and the Orchestrator job already contains a db connection, so could I query the db using powershell something like this:

    select top (1) reviewactivity where ParentGUID = 1234

    The query might have a few more joins… 🙂



  3. Simon says:

    No problem, I found a way around it with powershell. I added a string in the description field denoting which stage of approval the reviews were at, ‘Stage 1 Approval’ then filtered on that in the script.

    I replaced the Get Related Activities action in Orchestrator with this. Sorry about the wrapping…

    Set-ExecutionPolicy RemoteSigned

    $SMDefaultComputer = “SCSM01″

    $modules = (Get-Module | % {$}) -join ” ”
    if (!$modules.Contains(“SMLets”)) {
    Import-Module SMLets -ErrorVariable err -Force

    $SRObject = Get-SCSMObject -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -filter “ID -eq ”

    $ReviewActivities = Get-SCSMRelatedObject -SMObject $SRObject | ? {($_.displayname -like “RA*”) -and ($_.Description -eq ‘Stage 1 Approval’)}

    foreach ($RA in $ReviewActivities) {
    $RA_GUID = $RA.Get_ID()

    I published the variable $RA_GUID back to the databus and all was good.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s