I have a couple of Service Manager customers that want to automatically close incidents one day after they are resolved by a analyst. It will save them some manually work. In this post I will show you how to build a workflow that does this. The following example will close incidents that has been in resolved state for two hours. This workflow require smlets that you can download here.
- Start the Service Manager Authoring Tool.
- Create a new management pack, for example Contoso.AutoClose
- Create a new workflow
Run at a scheduled time or at scheduled intervals
Other interval, 2 hours
- Drag and drop the “Windows PowerShell Script” activiti from the toolbox to your workflow
- In the Details pane, click “Script body”
- Input the following script in the script bodyGet-SCSMIncident -Status Resolved -InactiveFor 02:00:00 | Set-SCSMIncident -Status Closed -comment “Closed due to duration of resolved period”The 02:00:00 is a TimeSpan declaration where 2 is the number of hours by hh:mm:ss. Observe that this will use the “lastmodified” timestamp for comparison and not the “resolved date”.
- On the script properties tab, input smcomlets as windows powershell snap-in required by the script
- Copy the ContosoAutoCloseWF.dll to the C:\Program Files\Microsoft System Center\Service Manager 2010 directory on your Management Server
- Import the management pack into Service Manager
- After a couple of hours, navigate to Administration/Workflows/Status and verify that your workflow is working
Your workflow will now automatically close all incidents that has been in resolved state for at least two hours, without any update. It will also add a comment to the action log saying “Closed due to duration of resolved period”. If you get any problems with your workflow the look at Travis post about troubleshooting workflows here.
You can download a example of this here AutoClose.
Update: Please note that SMCOMLETS is now named SMLETS. When you import this module or load it on the script properties page, make sure to use the correct name.
Update: Before start working with the cmdlets, please read this blogpost Properly Querying SCSM Using SMLets Get-SCSMObject cmdlet