2020-03-24 09:04:41 -04:00
|
|
|
function Register-IcingaEventLog()
|
|
|
|
|
{
|
2020-07-28 06:13:41 -04:00
|
|
|
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'
|
|
|
|
|
);
|
2020-03-24 09:04:41 -04:00
|
|
|
|
2020-07-28 06:13:41 -04:00
|
|
|
if ($Registered) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-06 13:06:59 -04:00
|
|
|
|
|
|
|
|
New-EventLog -LogName Application -Source 'Icinga for Windows';
|
2020-07-28 06:13:41 -04:00
|
|
|
} catch {
|
2020-08-06 13:06:59 -04:00
|
|
|
Exit-IcingaThrowException -ExceptionType 'Configuration' -ExceptionThrown $IcingaExceptions.Configuration.EventLogNotInstalled -Force;
|
2020-03-24 09:04:41 -04:00
|
|
|
}
|
|
|
|
|
}
|