Blog
By Scott Moss on 8/27/2010 6:56:33 PM • Rank (2211) • Views 2319
0

0

I’ve updated this post to use the proper Boolean for $TRUE and $FALSE. For more on that topic please see Jeffrey Snover‘s blog post http://blogs.msdn.com/b/powershell/archive/2006/12/24/boolean-values-and-operators.aspx

Here are some more handy PowerShell one liners that will get a count, a report or resolve alerts that were generated by rules, or mointors in their various Severity states, informational, warning, and critical. The final examples closes all alerts generated by rules, or all alerts generated by monitors. Each line should be one line of text in notepad if your having problems pasting them directly into the Operations Manager PowerShell console.

 

Get a count of informational alerts created by a rule
(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0''' | where-object {($_.IsMonitorAlert -eq $false)}).count

 

Get a count of informational alerts created by a monitor

(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0''' | where-object {($_.IsMonitorAlert -eq $true)}).count

 

Report listing of Informational Alerts created by a rule
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0''' | where-object {($_.IsMonitorAlert -eq $False)} |Group-Object Name |Sort -desc Count | select-Object Count, Name |Format-Table –auto

 

Report listing of Informational Alerts created by a monitor
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0''' | where-object {($_.IsMonitorAlert -eq $True)} |Group-Object Name |Sort -desc Count | select-Object Count, Name |Format-Table -auto

 

Resolve-Alerts that are created by a rule on informational alerts
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0''' | where-object {($_.IsMonitorAlert -eq $False)}| resolve-alert -comment "CLOSE informational Alerts created by Rules" | out-null

 

Resolve-Alerts that are created by a Monitor on informational alerts
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''0''' | where-object {($_.IsMonitorAlert -eq $True)}| resolve-alert -comment "CLOSE informational Alerts created by a Monitor" | out-null

 

Get a count of Warning alerts created by a rule
(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''1''' | where-object {($_.IsMonitorAlert -eq $false)}).count

 

Get a count of Warning alerts created by a monitor
(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''1''' | where-object {($_.IsMonitorAlert -eq $true)}).count

 

Report listing of Warning Alerts created by a rule
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''1''' | where-object {($_.IsMonitorAlert -eq $False)} |Group-Object Name |Sort -desc Count | select-Object Count, Name |Format-Table -auto

 

Report listing of Warning Alerts created by a monitor
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''1''' | where-object {($_.IsMonitorAlert -eq $True)} |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''' | where-object {($_.IsMonitorAlert -eq $False)} | resolve-alert -comment "CLOSE Warning Alerts created by Rules" | out-null

 

Resolve-Alerts that are created by a monitor on Warning alerts
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''1''' | where-object {($_.IsMonitorAlert -eq $True)} | resolve-alert -comment "CLOSE Warning Alerts created by Monitors" | out-null

 

Get a count of Critical alerts created by a rule
(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''2''' | where-object {($_.IsMonitorAlert -eq $False)}).count

 

Get a count of Critical alerts created by a monitor
(get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''2''' | where-object {($_.IsMonitorAlert -eq $True)}).count

 

Report listing of Critical Alerts created by a rule
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''2''' | where-object {($_.IsMonitorAlert -eq $False)} |Group-Object Name |Sort -desc Count | select-Object Count, Name |Format-Table –auto

 

Report listing of Critical Alerts created by a Monitor
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''2''' | where-object {($_.IsMonitorAlert -eq $True)} |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''' | where-object {($_.IsMonitorAlert -eq $False)} | resolve-alert -comment "CLOSE Critical Alerts created by Rules" | out-null

 

Resolve-Alerts that are created by a monitor on Critical alerts
get-alert -criteria 'ResolutionState = ''0'' AND Severity = ''2''' | where-object {($_.IsMonitorAlert -eq $True)} | 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''' | where-object {($_.IsMonitorAlert -eq $False)}| resolve-alert -comment "CLOSE ALL Alerts created by Rules" | out-null

 

Resolve all Alerts that are created by a monitor
get-alert -criteria 'ResolutionState = ''0''' | where-object {($_.IsMonitorAlert -eq $True)}| resolve-alert -comment "CLOSE ALL Alerts created by Monitors" | out-null

 

Enjoy the examples!

Comments - Comment RSS


Who Viewed
Who Reviewed
Categories
Related Pages
Shortened URL
http://tinyurl.com/23l83yx

Top Contributors
Featured Members
Pete Zerger
Points: 65622
Level: System Center Expert
Tommy Gunn
Points: 42748
Level: System Center Expert
Simon Skinner
Points: 40804
Level: System Center Expert
Stefan Koell
Points: 28999
Level: System Center Expert
Andreas Zuckerhut
Points: 27734
Level: System Center Expert