mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Fix exception on unregistered 'Icinga for Windows' EventLog on first run
Fixes #81 Fixes #82
This commit is contained in:
parent
31d34c5565
commit
d346dcb09d
1 changed files with 15 additions and 5 deletions
|
|
@ -1,5 +1,10 @@
|
|||
function Register-IcingaEventLog()
|
||||
{
|
||||
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'
|
||||
);
|
||||
|
|
@ -7,6 +12,11 @@ function Register-IcingaEventLog()
|
|||
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';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue