mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Added additional exception handling for EventLog Check
This commit is contained in:
parent
0d7954617c
commit
ac459d7fda
2 changed files with 9 additions and 3 deletions
|
|
@ -11,7 +11,8 @@
|
|||
|
||||
[hashtable]$Inputs = @{
|
||||
PerformanceCounter = 'A plugin failed to fetch Performance Counter information. Please ensure the counter is written properly and available on your system.';
|
||||
EventLog = 'Failed to fetch EventLog information. Please specify a LogName.';
|
||||
EventLogLogName = 'Failed to fetch EventLog information. Please specify a valid LogName.';
|
||||
EventLog = 'Failed to fetch EventLog information. Please check your inputs for EntryTypes and other categories and try again.';
|
||||
};
|
||||
|
||||
<#
|
||||
|
|
|
|||
|
|
@ -56,10 +56,15 @@ function Get-IcingaEventLog()
|
|||
$EventLogArguments.Add('Before', $Before);
|
||||
}
|
||||
|
||||
try {
|
||||
$events = Get-EventLog @EventLogArguments;
|
||||
} catch {
|
||||
Exit-IcingaThrowException -InputString $_.Exception -StringPattern 'ParameterBindingValidationException' -ExceptionType 'Input' -ExceptionThrown $IcingaExceptions.Inputs.EventLog;
|
||||
Exit-IcingaThrowException -InputString $_.Exception -StringPattern 'System.InvalidOperationException' -CustomMessage (-Join $LogName) -ExceptionType 'Input' -ExceptionThrown $IcingaExceptions.Inputs.EventLogLogName;
|
||||
Exit-IcingaThrowException -InputString $_.Exception -ExceptionType 'Unhandled' -Force;
|
||||
}
|
||||
|
||||
if ($null -ne $ExcludeEventId -Or $null -ne $ExcludeUsername -Or $null -ne $ExcludeEntryType -Or $null -ne $ExcludeMessage) {
|
||||
Write-Host 'Filtering started!'
|
||||
$filteredEvents = @();
|
||||
foreach ($event in $events) {
|
||||
# Filter out excluded event IDs
|
||||
|
|
|
|||
Loading…
Reference in a new issue