Merge two incidents
I have seen the question at Technet forums a number of times, is it possible to merge to incidents? In this post I have built a idea how to do it. When you run it you input two incident numbers. The first number is the incident that you want to keep, and the second number is the incident that you want to close. The script will move all comments from the action log in the first incident to the second, so your comments will be moved to the incident that will be keep open. This solution require smlets that you can download here.
I made some notes about how it works…
It includes a couple of scripts
- MergeInc.vbs, main vbscript
- GetComments.ps1, powershell script that export comments from the incident that you want to close. All comments are stored in C:\temp\export.txt
- UpdateIncident.ps1, powershell script that update the incident that you want to keep. It will be updated with all the old comments, in one large private comment in the action log
- CloseIncident.ps1, powershell script that will close the incident that you don’t want to keep anymore
You can run MergeInc.vbs as a task from the console, the same way I do with a script in this post. You could of course pick up a incident ID from the console when you run the console. In this example I have two incidents, IR67 and IR69. For some reason IR69 is a double of IR67 so we want to move the comments from IR69 to IR67 and close IR69.
Run the task and input IR69 and IR67.
Then IR69 is now closed and there is a comment in the action log
and if we look at IR67 the action log is now updated with all the old comments from IR69
It is not a optimized enterprise ready solution but it works. You can download my scripts here, Merge.
Auto Close Incidents
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
Name: ContosoAutoCloseWF
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
- Done!
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




Recent Comments