{"id":1629,"date":"2010-07-15T09:21:08","date_gmt":"2010-07-15T07:21:08","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=1629"},"modified":"2011-04-05T22:23:25","modified_gmt":"2011-04-05T20:23:25","slug":"auto-close-incidents","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=1629","title":{"rendered":"Auto Close Incidents"},"content":{"rendered":"<p>I have a couple of Service Manager customers that want to\u00c2\u00a0automatically 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 <a href=\"http:\/\/smlets.codeplex.com\/releases\/view\/47542\">here<\/a>.<\/p>\n<ol>\n<li>Start the Service Manager Authoring Tool.<\/li>\n<li>Create a new management pack, for example Contoso.AutoClose<\/li>\n<li>Create a new workflow<br \/>\nName: ContosoAutoCloseWF<br \/>\nRun at a scheduled time or at scheduled intervals<br \/>\nOther interval,\u00c2\u00a02 hours<\/li>\n<li>Drag and drop the &#8220;Windows PowerShell Script&#8221; activiti from the toolbox to your workflow<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2010\/07\/AutoClose01.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-1631\" title=\"AutoClose01\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2010\/07\/AutoClose01.jpg\" alt=\"\" width=\"277\" height=\"285\" \/><\/a><\/li>\n<li>In the Details pane, click &#8220;Script body&#8221;<\/li>\n<li>Input the following script in the script bodyGet-SCSMIncident -Status Resolved -InactiveFor 02:00:00 | Set-SCSMIncident -Status Closed -comment &#8220;Closed due to duration of resolved period&#8221;The 02:00:00 is a TimeSpan declaration where\u00c2\u00a02 is the number of hours by hh:mm:ss. Observe that this will use the &#8220;lastmodified&#8221; timestamp for comparison and not the &#8220;resolved date&#8221;.<\/li>\n<li>On the script properties tab, input smcomlets as windows powershell snap-in required by the script<\/li>\n<li>Copy the ContosoAutoCloseWF.dll to the C:\\Program Files\\Microsoft System Center\\Service Manager 2010 directory on your Management Server<\/li>\n<li>Import the management pack into Service Manager<\/li>\n<li>After a couple of hours,\u00c2\u00a0navigate to Administration\/Workflows\/Status and verify that your workflow is working<\/li>\n<li>Done!<\/li>\n<\/ol>\n<p>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 &#8220;Closed due to duration of resolved period&#8221;. If you get any problems with your workflow the look at Travis\u00c2\u00a0post about troubleshooting workflows <a href=\"http:\/\/blogs.technet.com\/b\/servicemanager\/archive\/2009\/12\/21\/troubleshooting-workflows-in-service-manager.aspx\">here<\/a>.<\/p>\n<p>You can download a example of this here\u00c2\u00a0<a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2010\/07\/AutoClose.zip\">AutoClose<\/a>.<\/p>\n<p><span style=\"color: #ff0000;\">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. <\/span><\/p>\n<p><span style=\"color: #ff0000;\">Update: Before start working with the cmdlets, please read this blogpost <a href=\"http:\/\/blogs.technet.com\/b\/servicemanager\/archive\/2011\/04\/04\/properly-querying-scsm-using-smlets-get-scsmobject-cmdlet.aspx\">Properly Querying SCSM Using SMLets Get-SCSMObject cmdlet<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a couple of Service Manager customers that want to\u00c2\u00a0automatically 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 &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=1629\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[25],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1629"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1629"}],"version-history":[{"count":11,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1629\/revisions"}],"predecessor-version":[{"id":1640,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1629\/revisions\/1640"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1629"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}