Automatically close incidents after x number of days
I had a request from a customer that the would like a workflow to close all resolved incidents, 7 days after they were resolved.
Several solutions exists on the internet, but I think this one is the most simple.
First you need to install the SCSM Powershell Cmdlets, as it includes a cmdlet called Get-SCSMIncident and Set-SCSMIncident. You can download it here, just follow the guide on how to install it on your SCSM Server.
- Start the Service Manager Authoring Tool. (Download it here, and make sure you have the latest SCSM CU applied)
- Create a new management pack, for example Close.Resolved.Incidents
- Rigth click Workflows and select Create
- Name: Closed_Resolved_Incidents
- Trigger: Run at Scheduled time
- Schedule: Everyday at 10:00 PM
- Drag and drop the “Windows PowerShell Script” activity from the activities toolbox to your workflow
- Name the script CloseResolvedIncidents
6. In the Details pane, click “..." in the Script body
7. Insert the following script:
Get-SCSMIncident -Status Resolved -InactiveFor 7.0:0:0 | Set-SCSMIncident -Status Closed -comment “Autoclosed after 7 days of being inactive and resolved”
Note: -InactiveFor 7.00:00:00 is a Powershell-TimeSpan and therefore means Days.Hours:Minutes;Seconds. You can change to InactiveFor to what timespan you need.
8. Save the Management Pack
9. In the Folder where you saved the Management pack, you will also have a dll-file located, for this example Closed_Resolved_Incidents.dll, copy the dll to C:\Program Files\Microsoft System Center\Service Manager 2010 directory on your Management Server
10. Import the management pack into Service Manager, either via the console or Powershell
11. Whenever you have scheduled the workflow to run, goto Administration, Workflows and check the status.
This will now run once a day and close all resolved incidents that have been inactive for e.g 7 days. The comment will be added as a an Analyst Comment.
Recently Cireson released a free MP that allows you to do the same, including SR, PR, CR and RR, and also with the ability to scheduled the workflow within the console. So if you don't want to created the MP, try to have a look at this one: http://www.cireson.com/app-store/scsm-auto-close/