This is a block of code I use since I have many activities nested in parallel activities and I want to make sure the parent is actually the SR or CR.
$SCSMServer = "localhost"
$RA = "RA12345"
$ParentRequestRelationshipID = "2da498be-0485-b2b2-d520-6ebd1698e61b"
$ReviewActivity = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Activity.ReviewActivity$ -ComputerName $SCSMServer) -ComputerName $SCSMServer -Filter "ID -eq $RA"
$RelatedParentRequest = (Get-SCSMRelationshipObject -ComputerName $SCSMServer -ByTarget $ReviewActivity | ?{$_.RelationshipID -eq $ParentRequestRelationshipID -and $_.IsDeleted -eq $False})
# Check to see if the parent is the SR or CR
If (-not($RelatedParentRequest.SourceObject.Name -like "CR*" -or $RelatedParentRequest.SourceObject.Name -like "SR*"))
{
DO {
$ParentActivity = Get-SCSMObject -Id $RelatedParentRequest.SourceObject.Id -ComputerName $SCSMServer
$RelatedParentRequest = (Get-SCSMRelationshipObject -ComputerName $SCSMServer -ByTarget $ParentActivity | ?{$_.RelationshipID -eq $ParentRequestRelationshipID -and $_.IsDeleted -eq $False})
$count += 1
} Until ($RelatedParentRequest.SourceObject.Name -like "CR*" -or $RelatedParentRequest.SourceObject.Name -like "SR*" -or $count -ige 10)
}