Created
December 3, 2017 19:44
-
-
Save LeeSartorelli/8bf030a7d0154fb1389cb638dec3ad15 to your computer and use it in GitHub Desktop.
Reset health of Disk space alerts that have changed state from Warning to Critical.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Reset health of Disk space alerts that have changed state from Warning to Critical. | |
.DESCRIPTION | |
This script is designed to be run as a scheduled task. It gets Logical Disk Free Low alerts that are critical and have a repeat count (indicating they have changed from warning to critical state), and resets the health of the monitor. | |
This causes a new critical alert to be raised, which will trigger the notification subscription. | |
.NOTES | |
Created by Lee Sartorelli 19/04/2016 | |
#> | |
Import-module OperationsManager | |
# get new, critical alerts with a repeat count and specified name | |
$alerts = get-scomalert -ResolutionState 0 -Severity 2| where {$_.RepeatCount -gt 0 -and $_.Name -like "Percentage Logical Disk Free Space is low"} | |
foreach($alert in $alerts) | |
{ | |
If ($alert) { | |
# Get the Monitoring Object (e.g. Windows Computer Object) | |
$MonObj = Get-SCOMMonitoringobject -Id $alert.MonitoringObjectId | |
# If the monitor exist and is unhealthy | |
If (($MonObj) -and ($MonObj.HealthState -ne "Success")) { | |
# Get the monitor for the alert | |
$Mon = Get-SCOMMonitor -Id $alert.MonitoringRuleId | |
# Reset health of the monitor | |
If ($Mon) { | |
$MonObj.ResetMonitoringState($Mon) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment