How to get a user that marked a manual activity as completed in SCSM
Last week one of our customers asked how to get a person who actually completed a manual activity. After some investigation, I’ve realized that the only source of that information is a history log of the manual activity.
It is a luck that SMlets has a commandlet named Get-SCSMObjectHistory. After some testing, I finished with this code:
import-module smlets
# set ID for a manual activity
$MA_Id="MA235"
# get the manual activity
$MA = Get-SCSMObject-class (Get-SCSMClass-name System.WorkItem.Activity.ManualActivity) -filter "Id -eq $MA_Id"
#get-history
$h = Get-SCSMObjectHistory -Object $MA
# get a user name that completed MA
foreach ($case in $h.history.GetEnumerator()) {foreach ($change in $case.changes | where-object {$_.newvalue -like "ActivityStatusEnum.Completed"}) {$case.UserName}}