{"id":1375,"date":"2010-03-23T23:25:16","date_gmt":"2010-03-23T21:25:16","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=1375"},"modified":"2010-09-01T12:14:07","modified_gmt":"2010-09-01T10:14:07","slug":"update-resolution-state-with-a-script","status":"publish","type":"post","link":"https:\/\/contoso.se\/blog\/?p=1375","title":{"rendered":"Update resolution state with a script"},"content":{"rendered":"<p>This is a script you can use to update resolution state. It will look\u00c2\u00a0at all new alerts (resolutionstate = 0) and see if the alert description contains &#8220;domain&#8221; or &#8220;AD&#8221;, if they do, the script will set a new resolution state. The ID for the resolution state can be found under alert settings in the administration workspace, in the Operations Manager console. You can schedule task to run this script every X minute to update all new alerts.<\/p>\n<blockquote><p>$RMS = &#8220;myRMSHost&#8221;<\/p>\n<p>Add-PSSnapin &#8220;Microsoft.EnterpriseManagement.OperationsManager.Client&#8221;<br \/>\nSet-Location &#8220;OperationsManagerMonitoring::&#8221;<br \/>\nNew-ManagementGroupConnection -ConnectionString:$RMS<br \/>\nSet-Location $RMS<\/p>\n<p>$resState =\u00c2\u00a042\u00c2\u00a0<br \/>\n$alerts = get-alert -criteria &#8216;ResolutionState =&#8221;0&#8243;&#8216; | where-object {($_.Description -match &#8220;AD&#8221;) -or ($_.Description -match &#8220;domain&#8221;)}<br \/>\nIf ($alerts) \u00c2\u00a0{<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0foreach ($alert in $alerts)<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0{<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0$alert.ResolutionState = $resState<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0$alert.Update(&#8220;&#8221;)<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0}<br \/>\n\u00c2\u00a0\u00c2\u00a0}\u00c2\u00a0<\/p><\/blockquote>\n<p>The schedule task command can be<\/p>\n<blockquote><p>C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe -command C:\\myscripts\\change_resolutionstate.ps1<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This is a script you can use to update resolution state. It will look\u00c2\u00a0at all new alerts (resolutionstate = 0) and see if the alert description contains &#8220;domain&#8221; or &#8220;AD&#8221;, if they do, the script will set a new resolution state. The ID for the resolution state can be found under alert settings in the &hellip; <a href=\"https:\/\/contoso.se\/blog\/?p=1375\">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":[13,19],"tags":[],"_links":{"self":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1375"}],"collection":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1375"}],"version-history":[{"count":6,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1375\/revisions"}],"predecessor-version":[{"id":1745,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1375\/revisions\/1745"}],"wp:attachment":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}