Skip to content

Commit

Permalink
Fix exception on unregistered 'Icinga for Windows' EventLog on first run
Browse files Browse the repository at this point in the history
Fixes #81
Fixes #82
  • Loading branch information
LordHepipud committed Jul 28, 2020
1 parent 31d34c5 commit d346dcb
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/core/logging/Register-IcingaEventLog.psm1
@@ -1,11 +1,21 @@
function Register-IcingaEventLog()
{
$Registered = [System.Diagnostics.EventLog]::SourceExists(
'Icinga for Windows'
);
try {
# Run this in a Try-Catch-Block, as we will run into an exception if it is not
# present in the Application where it should be once we try to load the
# Security log. If it is not found in the "public" Event-Log data, the
# App is not registered
$Registered = [System.Diagnostics.EventLog]::SourceExists(
'Icinga for Windows'
);

if ($Registered) {
return;
if ($Registered) {
return;
}
} catch {
# Nothing to handle here. We should simply register our application
# whtin the Application Event-Log. We will only run into this catch
# block if the app was not registered.
}

New-EventLog -LogName Application -Source 'Icinga for Windows';
Expand Down

0 comments on commit d346dcb

Please sign in to comment.