question

fr43nk avatar image
0 Votes"
fr43nk asked ·

SCSM Smlets update impacted Services

I need to query the impacted services.
With Incidents and Change Requests I already accomplished that.
But I would need to query the impacted services in Service Requests, Problems and Release Records as well.

Can someone guide me how to list the impacted services?

Thats what I use find certain impacted services on Incidents and Change Requests.

$rel = Get-SCSMRelationship -Name "System.WorkItemAboutConfigItem"
$WI = Get-SCSMClassInstance -Class (Get-SCSMClass -Name System.WorkItem.Incident) | ?{$.ID -eq "xxxxxx"}
$CIs = $WI.GetRelatedObjectsWhereSource($rel.ID) | ?{$
.EnterpriseManagementObject.DisplayName -like "<query>"}

That doesn't work with Service Requests, Problems and Release Records.

msc-service-manager-general
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered ·

@fr43nk

There are different relationships available for Work Items. Maybe this is helpful:

 Import-Module SMLets
    
 $sr = "SR1647"
 $pr = "PR668"
 $rr = "RR730"
    
 # Some variables
 $srClass = Get-SCSMClass -Name System.WorkItem.ServiceRequest$
 $prClass = Get-SCSMClass -Name System.WorkItem.Problem$
 $rrClass = Get-SCSMClass -Name System.WorkItem.ReleaseRecord$
 $relWIaboutCI = Get-SCSMRelationshipClass -Name System.WorkItemAboutConfigItem                                                  
 $relWIrelatesCI = Get-SCSMRelationshipClass -Name System.WorkItemRelatesToConfigItem
 $relWIimpactsService = Get-SCSMRelationshipClass -Name System.WorkItemImpactsService
    
 #  Get SR object
 $srObj = Get-SCSMObject -Class $srClass -Filter "ID -eq $sr"
 # Get about CIs -> In SR form - Affected Configuration Items
 Get-SCSMRelatedObject -SMObject $srObj -Relationship $relWIaboutCI
 # Get related CIs -> In SR form - Configuration Item: Computers, Services and People
 Get-SCSMRelatedObject -SMObject $srObj -Relationship $relWIrelatesCI
    
 # Get PR object
 $prObj = Get-SCSMObject -Class $prClass -Filter "ID -eq $pr"
 # Get about CIs -> In PR form - Affected Services 
 Get-SCSMRelatedObject -SMObject $prObj -Relationship $relWIaboutCI
 # Get related CIs -> In PR form - Configuration Item: Computers, Services and People
 Get-SCSMRelatedObject -SMObject $prObj -Relationship $relWIrelatesCI
    
 # Get RR object
 $rrObj = Get-SCSMObject -Class $rrClass -Filter "ID -eq $rr"
 # Get related CIs -> In RR form - Configuration Item: Computers, Services and People
 Get-SCSMRelatedObject -SMObject $rrObj -Relationship $relWIrelatesCI
 # Get affected CIs -> In RR form - Affected Service
 Get-SCSMRelatedObject -SMObject $rrObj -Relationship $relWIimpactsService


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you, that was exactly what I was looking for.
Works like a charm.

0 Votes 0 ·