Our System Center Memo

SCSM Incident Auto Close Guide

Having a request from the customer to automatically close an incident that has been resolved for a period of time is very common. But how do we do that in Service Manager? I’ll show you a step by step with screenshots here.

Before I begin, take note that I did not write this script. The solution came from Marcel Zehner, and I simply shorten the script for my own needs. I also felt that there was a need to have a step by step with screenshot guide. To view the original, go to his blog here. He has many other useful solutions as well which will benefit you.

Ok for starters, you will need to download the SMLets Powershell Module. After download, extract and copy the SMLets folder, and paste it in %\Windows\System32\WindowsPowerShell\v1.0\Modules.


1. Launch the Authoring Manager. Under File, click New. Specify a location and a name for your Management Pack, click Save.



2. Under Management Pack Explorer, right click on Workflow, click Create.



3. Key in a Name and Description if needed. You cannot have spacings in the Name. Click Advanced if you want to change the retry interval should the workflow fail, or specify the maximum time the workflow is allowed to run. Click Next.



4. We’d like the workflow to run on a specific time, so I’m going to select the first option. Click Next.



5. I want the workflow to run on every midnight, so my configuration is as below. If you’re testing the workflow, maybe set it to run every 5 minutes. Click Next.



6. Confirm the Summary, click Create.



7. Click Close.



8. You should be seeing this screen now. On the Activities Toolbox, look for Windows PowerShell Script, and drag it to the workflow, and drop it in the middle.



9. You will then see this screen. On the Details pane, look for Script Body. There will be a red exclamation mark. Click the blank field beside it and a button will appear, click it and another screen will appear.



10. In the Script Body page, key in exactly this. This script will close all Incident tickets that has been resolved and has not been updated in the last 5 days.

$Date = (get-date);
$DateString = $Date.toString();

import-module smlets;

$5DaysOld = (get-date).addhours(-120);

$IncidentsToClose = Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Incident$) | where{$_.lastmodified -lt $5DaysOld -AND $_.Status -like "*Resol*"};

$IncidentsToClose | Set-SCSMObject -property Status -Value Closed;


Under Script Properties, leave everything blank. Click Ok.


Note! If you’re doing testing, you might not want to wait for 5 days. So you can replace

$5DaysOld = (get-date).addhours(-120); with $5DaysOld = (get-date).addminutes(-1);

This will then close all tickets that has been resolved for 1 minute.


Note! This script will only work with SMLets Beta 3. The Beta 2 script is a little different and I’ve already updated this guide to cater to Beta 3’s script. If you’re looking for the Beta 2 script, I’ll actually suggest you to upgrade your SMLets to Beta 3 and use this script instead.


11. The next step is to save your Management Pack. If you get this error when saving, go back to the Script Body, check all the “ and – again. Since you’re copying from the web, the “ and – might not be recognizable, just delete and retype the special characters.



12. After saving the Management Pack, open the folder that you saved the MP. You’ll see 5 files. Only 2 are needed. First, copy the DLL file and paste it into %Program Files\Microsoft System Center\Service Manager 2010



13. Next, open your SCSM Console, go to Administration, right click Management Packs and click on Import.



14. Browse to the same folder that you saved the Management Pack, and select the XML file.



15. Click Import, then Ok.



16. You’re done. To see if the workflow actually ran, go to Administration > Workflow > Status. Look for the workflow you just created, and check the logs.


March 31, 2011 - Posted by | System Center Service Manager (SCSM)


  1. Thanks for the screens shots, very useful in comparison to other sites, especially for those new to Power shell scripts!
    I found I could only get the script to run by putting the DLL in the

    %\Program Files\Microsoft System Center\Service Manager 2010

    folder, not in the System Center Service Packs folder as detailed above.

    Also your html version of the script above has the lower line missing which actually changes the status of the Incident. So if anyone cuts and Pastes this without noticing, it wont work!


    Comment by Dave | April 14, 2011 | Reply

    • Hey Dave,

      Glad this helped. And thanks for pointing out the errors! Wouldn’t have noticed it myself 🙂


      Comment by Memo Admin | April 15, 2011 | Reply

  2. Thank you for the visual tutorial. I ran the script and it shows a success in the workflow status, but my incidents still show as resolved for a minute test, even for ones I just resolved in the console. I actually typed in the commands. Did I miss something?


    Comment by Darius | April 27, 2011 | Reply

    • Hi Darius,

      Can you email me the script that you used? My email is You manually typed in the command in Windows PowerShell too? If you followed my script it will only close incidents that has been resolved by 5 days unless you change this line $5DaysOld = (get-date).addhours(-120); to $5DaysOld = (get-date).addminutes(-1); then it will close incidents that has been resolved by 1 minute. Do email me, I’ll assist you further 🙂


      Comment by James | April 27, 2011 | Reply

  3. James,

    Thank you very much for helping out a Powershell newbie here. And, we found an update to the script as well due to smlet v3. Cheers!


    Comment by Darius | April 28, 2011 | Reply

    • You’re welcome Darius, it was a productive session indeed 🙂


      Comment by James | April 28, 2011 | Reply

  4. I tried the script above and it ran sucessfully according to the status log but didnt close the incidents either. what did you do to get it working?

    Comment by Dave | June 21, 2011 | Reply

    • Hey Dave,

      I’m assuming you’re the one I’ve been communicating through email, lets continue our conversation there and see if we can find something out 🙂


      Comment by James | June 29, 2011 | Reply

  5. Dane what will be the missing html code because workflow giving error 2130771918

    Comment by shumail | December 20, 2011 | Reply

    • Hi Shumail,

      I didn’t notice that there was a comment pending. Do you still need help on this? I didn’t quite get what was the question though.

      James Yeoh

      Comment by James | January 11, 2012 | Reply

  6. what about the SCSM 2012 SP1? Will it works with 2012 SP1??

    Comment by Syed | December 20, 2013 | Reply

    • It will, but I suggest you try out Cireson’s Auto Close App, it’s much easier and it’s free.

      Comment by James | July 17, 2014 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: