mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
Merge pull request #710 from Icinga:fix/errors_for_non_admin_shells
Fix: Errors for non-admin shells introduced with v1.12.0 Fixes various console errors while running Icinga for Windows outside of an administrative shell
This commit is contained in:
commit
45c4a2ba60
3 changed files with 16 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
|||
### Bugfixes
|
||||
|
||||
* [#707](https://github.com/Icinga/icinga-powershell-framework/pull/707) Fixes size of the `Icinga for Windows` eventlog by setting it to `20MiB`, allowing to store more events before they are overwritten
|
||||
* [#710](https://github.com/Icinga/icinga-powershell-framework/pull/710) Fixes various console errors while running Icinga for Windows outside of an administrative shell
|
||||
|
||||
## 1.12.0 (2024-03-26)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ function Set-IcingaServiceEnvironment()
|
|||
return;
|
||||
}
|
||||
|
||||
# Don't do anything if we are not inside an administrative shell
|
||||
if ((Test-AdministrativeShell) -eq $FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Use scheduled tasks to fetch our current service configuration for faster load times afterwards
|
||||
$IcingaService = Invoke-IcingaWindowsScheduledTask -JobType GetWindowsService -ObjectName 'icinga2';
|
||||
$PowerShellService = Invoke-IcingaWindowsScheduledTask -JobType GetWindowsService -ObjectName 'icingapowershell';
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ function Register-IcingaEventLog()
|
|||
[string]$LogName = $null
|
||||
);
|
||||
|
||||
if ((Test-AdministrativeShell) -eq $FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($LogName)) {
|
||||
New-EventLog -LogName 'Icinga for Windows' -Source 'IfW::Framework' -ErrorAction SilentlyContinue;
|
||||
New-EventLog -LogName 'Icinga for Windows' -Source 'IfW::Service' -ErrorAction SilentlyContinue;
|
||||
|
|
@ -15,6 +19,12 @@ function Register-IcingaEventLog()
|
|||
}
|
||||
|
||||
$IfWEventLog = Get-WinEvent -ListLog 'Icinga for Windows';
|
||||
|
||||
# In case the value is already set, nothing to do
|
||||
if ($IfWEventLog.MaximumSizeInBytes -ge 20971520) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Set the size to 20MiB
|
||||
$IfWEventLog.MaximumSizeInBytes = 20971520;
|
||||
$IfWEventLog.SaveChanges();
|
||||
|
|
|
|||
Loading…
Reference in a new issue