Automatically Closing Completed SCSM Service Requests with Orchestrator

Automatically Closing Completed SCSM Service Requests with Orchestrator

  • Comments 7
  • Likes

This is a guest blog post by Mark Newton, one of our community contributors.  Thanks for sharing Mark!

========================================

I have set up a number of ‘Service Requests’ in SCSM 2012 which are all working great. However what we were finding was that all our requests once finished were in the SCSM console with a status of ‘Completed’. We were having to go in periodically and ‘Close’ all the request so that they will be eventually purged from the console. I thought what a simple job for Orchestrator to do and here is how I set it up.

This is what the run book looks like:

clip_image002

1. Monitor Date/Time is just setting what time do I want the run book to check for completed service requests.

clip_image004

2. -7 days is essentially saying check 7 days back.

clip_image006

3. Get Completed SRF gets service requests which are ‘Completed’ and older than 7 days using the information available on the bus from –7 days.

clip_image008

4. On the line between Get Completed SRF and Close SRF is ‘Only if value > 0’. This ensures that the next step is only carried out if there are service requests which have completed.

clip_image010

5. Close SRF closes the service request, sets a closed date and adds a description.

clip_image012

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Travis: Cool! Hey is this doable in the Authoring tool workflow generator?

  • Thanks Travis and Mark! Let me share a solution for Greg and the community. Below a script in powershell. It uses native Service Manager commandlets so it's easy to add in Authoring Tool. Here you are:

    CD 'C:\Program Files\Microsoft System Center 2012\Service Manager\Powershell'

    Import-Module .\System.Center.Service.Manager.psd1

    $SomeDaysOld = (get-date).adddays(-7)

    $UNC_Now = (get-date).ToUniversalTime()

    $IncidentClass = Get-SCClass -Name System.workitem.incident

    $Inc_resolved = Get-SCClassInstance -Class $IncidentClass -Filter "Status -eq IncidentStatusEnum.Resolved" | ?{$_.ResolvedDate -lt $SomeDaysOld}

    If ($Inc_resolved -ne $null)

       {

       foreach ($Inc in $Inc_resolved)

           {

               $Inc.Status = "bd0ae7c4-3315-2eb3-7933-82dfc482dbaf"

               $Inc.ClosedDate = $UNC_Now

               Update-SCClassInstance -Instance $Inc

           }

       }

    $SRclass = Get-SCClass -Name System.WorkItem.ServiceRequest

    $SR_completed = Get-SCClassInstance -Class $SRclass -Filter "Status -eq ServiceRequestStatusEnum.Completed" | ?{$_.CompletedDate -lt $SomeDaysOld}

    $SR_failed = Get-SCClassInstance -Class $SRclass -Filter "Status -eq ServiceRequestStatusEnum.Failed" | ?{$_.CompletedDate -lt $SomeDaysOld}

    $SR_cancelled = Get-SCClassInstance -Class $SRclass -Filter "Status -eq ServiceRequestStatusEnum.Canceled" | ?{$_.CompletedDate -lt $SomeDaysOld}

    If ($SR_completed -ne $null)

       {

       foreach ($SR in $SR_completed)

           {

               $SR.Status = "c7b65747-f99e-c108-1e17-3c1062138fc4"

               $SR.ClosedDate = $UNC_Now

               Update-SCClassInstance -Instance $SR

           }

       }

    If ($SR_failed -ne $null)

       {

       foreach ($SR in $SR_failed)

           {

               $SR.Status = "c7b65747-f99e-c108-1e17-3c1062138fc4"

               $SR.ClosedDate = $UNC_Now

              Update-SCClassInstance -Instance $SR

           }

       }

    If ($SR_cancelled -ne $null)

       {

       foreach ($SR in $SR_cancelled)

           {

               $SR.Status = "c7b65747-f99e-c108-1e17-3c1062138fc4"

               $SR.ClosedDate = $UNC_Now

              Update-SCClassInstance -Instance $SR

           }

       }

    Remove-Module System.Center.Service.Manager

  • m getting an error SC Object GUID null or empty. when i run my runbook i’m asked to give the Acticity ID. I am giving the ID which i have at my runbook in console i.e. 81fba1eeee054d89bf5c78aec05e0de4

    Till second steps it works then at get relationship it give the error

  • @Greg - Refer to this post dynamicdatacenter.wordpress.com/.../auto-close-resolved-incidents for an alternative method in the Authoring Tool.

  • I've got the same issue as Saniya - Get Object is returning a null/empty value.

  • i want to create a custom workflow which will change service request status to IN PROGRESS when assign to someone.

    if any one share powershell script

  • Or... Use a completely free App that you can schedule all work items to close within a # of days of being Completed or Resolved.

    www.cireson.com/.../scsm-auto-close

    Fill out the form at the bottom of the page and it will be emailed to you automatically.