More get-alert IsMonitorAlert powershell one liners for SCOM
Here are some more handy powershell one liners that will get a count, a report or resolve alerts that were generated by rules in their various Severity states, informational, warning, and critical. The final one liner closes all alerts generated by rules.
Get a count of informational alerts created by a rule
-------------------------------------------------------
(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0'' AND IsMonitorAlert = ''False''').count
Report listing of Informational Alerts created by a rule
----------------------------------------------------------
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0'' AND IsMonitorAlert = ''False'''|Group-Object Name |Sort -desc Count | select-Object Count, Name |Format-Table -auto
Resolve-Alerts that are created by a rule on infrmational alerts
-----------------------------------------------------------------
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0'' AND IsMonitorAlert = ''False'''| resolve-alert -comment "CLOSE informational Alerts created by Rules" | out-null
Get a count of Warning alerts created by a rule
------------------------------------------------
(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''1'' AND IsMonitorAlert = ''False''').count
Report listing of Warning Alerts created by a rule
--------------------------------------------------
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''1'' AND IsMonitorAlert = ''False'''|Group-Object Name |Sort -desc Count | select-Object Count, Name |Format-Table -auto
Resolve-Alerts that are created by a rule on Warning alerts
------------------------------------------------------------
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''1'' AND IsMonitorAlert = ''False'''| resolve-alert -comment "CLOSE Warning Alerts created by Rules" | out-null
Get a count of Critical alerts created by a rule
-------------------------------------------------
(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''2'' AND IsMonitorAlert = ''False''').count
Report listing of Critical Alerts created by a rule
----------------------------------------------------
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''2'' AND IsMonitorAlert = ''False'''|Group-Object Name |Sort -desc Count | select-Object Count, Name |Format-Table -auto
Resolve-Alerts that are created by a rule on Critical alerts
-------------------------------------------------------------
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''2'' AND IsMonitorAlert = ''False'''| resolve-alert -comment "CLOSE Critical Alerts created by Rules" | out-null
Resolve all Alerts that are created by a rule
----------------------------------------------
get-alert -criteria 'ResolutionState = ''0'' AND IsMonitorAlert = ''False'''| resolve-alert -comment "CLOSE ALL Alerts created by Rules" | out-null