trying to email users if more than one manual activity has been completed for an incident.

May 24, 2013 at 7:57 PM
Hello - Currently when Service Manager has related items such as a manual activity the subscriptions I created can basically reply back whenever the first manual activity has been completed. If another one which is in progress in that same incident has been completed it will not send a notification out. So I decided to see if I could create something using Powershell but am stuck. Here is what I have so far but am not sure I have all the variables needed to actually do anything. What i'd like to do is setup a schedule task that runs every 5 minutes and that the script goes through and checks to see if any manual activitys have been completed in the last 5 minutes and it send out an e-mail to the incident assigned to user. Your assistance would greatly be appreciated.

Import-Module smlets

Variables

$Activity = Get-SCSMObject -Class(Get-SCSMClass -Name System.workitem.activity.manualactivity$)|Where{$_Status.Displayname -like "In Progess"}
$UserClass = Get-SCSMCLass -Name Microsoft.Ad.User$
$User = Get-SCSMObject -Class $UserClass -Filter "DisplayName -eq $Implementer"
$ImplementerRelationship = Get-SCSMRelationshipClass -Name System.WorkItemAssignedtouser$
$Workitemcontainsactivity = Get-SCSMRelationShipClass -Name System.Workitemcontainsactivity
$Completed = Get-SCSMEnumeration -Name ActivityStatusEnum.Completed