Powershell one-liners for alert management

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

Advertisements
This entry was posted in Misc Stuff, Powershell for SCOM and tagged , , . Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s