List all "Service Requests" (children) of a (parent) "Service Offering" or "Request Offering"

Jul 24, 2013 at 8:51 PM
I am sure this is a stupid question with a simple answer but....

I can list ALL "Service Requests" but how do I only show those service requests that are part of a certain Service Offering or Request Offering (either)

Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$) -Filter "ParentServiceOfferingGUID -eq 137f7673-8486-9260-8265-a808b99b7c8a" | Format-Table ID, Status

<returns only those service requests belonging to ServiceOffering (or Request Offering) with the GUID above>
Id Status

SR1410 Canceled
SR2592 Completed
SR2609 Completed

Thanks in advance to anyone who can help.
Jul 29, 2013 at 1:46 PM
I was actually able to answer this myself. Hopefully someone will find this useful.

$RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name System.RequestOffering$) -Filter "DisplayName -eq My Test Request Offering)")
$ServiceRequests = (Get-SCSMRelationshipObject -ByTarget $RequestOffering | ?{$_.RelationshipID -eq "2730587F-3D88-A4E4-42D8-08CF94535A6E"}).SourceObject

They key elements are in bold. To get the relationship ID run the following where SR56346 is one of your service requests:

$ServiceRequest = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$) -Filter "ID -eq SR56346"
Get-SCSMRelationshipObject -BySource $ServiceRequest

[OUTPUT WILL LOOK LIKE THIS] - Find the one with the source as your service request as the SOURCE and your Request Offering as the Target. The RelationshipID is the GUID you are looking for.

SourceObject : SR56346 - My Test Service Request
TargetObject : My Test Request Offering
RelationshipId : 2730587f-3d88-a4e4-42d8-08cf94535a6e
IsDeleted : False
Values : {}
LastModified : 7/10/2013 9:05:46 PM
IsNew : False
HasChanges : False
Id : df58b383-10a6-80ef-5e85-e1907d60d839
ManagementGroup : MyManagementGroup
ManagementGroupId : d9845f09-a477-ede8-c9ec-abe62114ccf9

Here are some others as examples


RELATIONSHIP: Service Request to Request Offering

$ServiceRequest = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ServiceRequest$) -Filter "ID -eq SR56346"
$RequestOffering = (Get-SCSMRelationshipObject -BySource $ServiceRequest | ?{$_.RelationshipID -eq "2730587F-3D88-A4E4-42D8-08CF94535A6E"}).TargetObject

RELATIONSHIP: Service Offering To Request Offering

$ServiceOffering = Get-SCSMObject -Class (Get-SCSMClass -Name System.ServiceOffering$) -Filter "DisplayName -eq My Test Service Offering"
$RequestOffering = (Get-SCSMRelationshipObject -BySource $ServiceOffering | ?{$_.RelationshipID -eq "be417a55-6622-0fc3-fcea-90cd23e0fc23"}).TargetObject

RELATIONSHIP: Request Offering to Service Requests (the one above)

$RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name System.RequestOffering$) -Filter "DisplayName -eq My Test Request Offering")
$ServiceRequests = (Get-SCSMRelationshipObject -ByTarget $RequestOffering | ?{$_.RelationshipID -eq "2730587F-3D88-A4E4-42D8-08CF94535A6E"}).SourceObject