You notice that you receive irrelevant error e-mail notifications as these errors are recovered by subsequent similar jobs.
For instance, you have a protected server which fails taking successful snapshots at least once a day due to another backup performed by a third party application.
You determine that you want to receive error notifications via E-mail but only after a critical number of errors was reached.
PowerShell Scripting Disclaimer:
This script is provided "as is" for the purpose of illustrating how product tasks may be performed in conjunction with PowerShell. Support shall not be liable for any direct, indirect, incidental, consequential, or other damage alleged in connection with the furnishing or use of this script or of the principles it demonstrates. See PowerShell Scripting Support for more information.
A Powershell script addressing the issue has been prepared.
The script keeps track of the errors on the core. When specific errors surpass a threshold, it sends an e-mail with the information and resets the counters. The script allows setting up e-mail notifications and adds the settings to the scripts body.
The current version requires Powershell 3.0 or later and should be run on the core.
If successful, the script will be expanded to be run remotely thus able to cover multiple cores.
The script takes a number of parameters as shown below:
Allows setting up the e-mail. The results are included in a new script with a changed name, saved in the same folder as the original script. For instance errornotification.1.ps1 becomes errornotification.1_2015-03-18.email.ps1 The new script is located in the same folder as the original one.
Very important parameter. Takes into consideration the changes since the last run of the script, thus giving accurate results. I.E. te script is set to run every day but, for some reason it is disabled for a couiple of days. The results will reflect the errors since the last run. Other example is if the script is run more often than the queried time interval. For instance if the script is supposed to run every 24 hours and for some reason an user is running it manually sooner, the queried interval will not be 24 hours but the time since the script was run earlier that day, thus no false positives are signaled.
Default c.xml and located in the same folder as the script. The xml file containing running information. can be set to be created in a different folder or, if running a report not taking into considertion current values is needed. (i.e. Agents passing a specific error threshold for the previous month. Reverting to the old xml file will continue the the current stream of results.
Querying interval; superseeded by the enforce interval parameter
Default 7 days. The duration of keeping recorded errors which do not make the threshold. For instance, if the threshold is 3 errors and a protected serverhas only 2 errors in the last 7 days, these errors are removed.
Default 3 errors. The error critical mass which triggers a notification e-mail.
Reserved for future use
Reserved for future use
PS C:\scripts> .\errornotification.1.ps1 -setupemail
PS C:\scripts> .\errornotification.1_2015-03-18.email.ps1 -days 7 -threshold 5
PS C:\scripts> .\errornotification.1_2015-03-18.email.ps1 -days 3 -threshold 3 -days expired 5 -enforce interval
The code for the script is attached to this KB.
The script is fully documented and the usage information can be retrieved by running:
PS C:\scripts> get-help .\errornotification.1_2015-03-18.email.ps1 -full