Fixes permission error on EventLog registration by printing proper error message

Fixes #81
This commit is contained in:
Christian Stein 2020-08-06 19:06:59 +02:00
parent 22f341bd26
commit 47272bd243
4 changed files with 10 additions and 9 deletions

View file

@ -36,7 +36,7 @@ Check Command configuration generated by Icinga for Windows 1.2.0 require Icinga
* [#78](https://github.com/Icinga/icinga-powershell-framework/issues/78) Fix Icinga Agent package fetching for x86 architecture
* [#79](https://github.com/Icinga/icinga-powershell-framework/issues/79) Fix ConvertTo-Seconds to output valid numeric data with multiple digits
* [#81](https://github.com/Icinga/icinga-powershell-framework/issues/81), [#82](https://github.com/Icinga/icinga-powershell-framework/issues/82) Fix error on EventLog initialising in case `Icinga for Windows` application is not registered on new machines
* [#81](https://github.com/Icinga/icinga-powershell-framework/issues/81), [#82](https://github.com/Icinga/icinga-powershell-framework/issues/82) Fix error on EventLog initialising in case `Icinga for Windows` application is not registered on new machines and throws proper error message on plugin execution on how to resolve it
* [#84](https://github.com/Icinga/icinga-powershell-framework/issues/84), Fix conversion of `ConvertTo-Seconds` and `ConvertTo-SecondsFromIcingaThresholds` while the input value is `$null`
* [#85](https://github.com/Icinga/icinga-powershell-framework/issues/85), Fix incorrect handling to empty service user password which was configured as empty `String` instead of `$null` `SecureString` object
* [#89](https://github.com/Icinga/icinga-powershell-framework/issues/89), Fix file type question during `Get-IcingaCheckCommandConfig` generation in Windows 2012 R2 and older

View file

@ -29,8 +29,6 @@ function Use-Icinga()
Import-IcingaLib '\' -Init;
if ($LibOnly -eq $FALSE) {
Register-IcingaEventLog;
$global:IcingaThreads = [hashtable]::Synchronized(@{});
$global:IcingaThreadContent = [hashtable]::Synchronized(@{});
$global:IcingaThreadPool = [hashtable]::Synchronized(@{});
@ -73,6 +71,10 @@ function Use-Icinga()
-Value $entry[$event] | Out-Null;
}
}
if ($LibOnly -eq $FALSE) {
Register-IcingaEventLog;
}
}
function Import-IcingaLib()

View file

@ -12,11 +12,9 @@ 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';
} catch {
Exit-IcingaThrowException -ExceptionType 'Configuration' -ExceptionThrown $IcingaExceptions.Configuration.EventLogNotInstalled -Force;
}
}

View file

@ -25,6 +25,7 @@
PluginArgumentMissing = 'Your plugin argument configuration is missing mandatory arguments. This is error is caused when mandatory or required arguments are missing from a plugin call and the operation is unable to process without them.';
PluginNotInstalled = 'The plugin assigned to this service check seems not to be installed on this machine. Please review your service check configuration for spelling errors and check if the plugin is installed and executable on this machine by PowerShell.';
PluginNotAssigned = 'Your check for this service could not be processed because it seems like no valid Cmdlet was assigned to the check command. Please review your check command to ensure that a valid Cmdlet is assigned and executed by a PowerShell call.';
EventLogNotInstalled = 'Your Icinga PowerShell Framework has been executed by an unprivileged user before it was properly installed. The Windows EventLog application could not be registered because the current user has insufficient permissions. Please log into the machine and run "Use-Icinga" once from an administrative shell to complete the setup process. Once done this error should vanish.';
}
<#