Quantcast
Channel: SCSM PowerShell Cmdlets
Viewing all articles
Browse latest Browse all 306

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

$
0
0
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
$ServiceRequests

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

RELATIONSHIPS

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
$RequestOffering.Get_ID()

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
$RequestOffering

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
$ServiceRequests

Viewing all articles
Browse latest Browse all 306

Trending Articles