From 6598eb0bb850d4a6e9bfbfe024fd818d9d22ec5f Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Sat, 29 Jan 2022 00:40:41 +0100 Subject: [PATCH] Fixes install icinga security for admin shell --- doc/100-General/10-Changelog.md | 1 + lib/core/windows/Install-IcingaSecurity.psm1 | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 158798a..c252e04 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -37,6 +37,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#452](https://github.com/Icinga/icinga-powershell-framework/pull/452) Fixes unhandled `true` output on the console while running the installer * [#454](https://github.com/Icinga/icinga-powershell-framework/pull/454) Fixes JEA catalog compiler and background daemon execution in JEA context * [#456](https://github.com/Icinga/icinga-powershell-framework/pull/456) Fixes JEA service error count not resetting itself after a certain amount of time without errors +* [#458](https://github.com/Icinga/icinga-powershell-framework/pull/458) Fixes `Install-IcingaSecurity` which should only run in an administrative shell ### Enhancements diff --git a/lib/core/windows/Install-IcingaSecurity.psm1 b/lib/core/windows/Install-IcingaSecurity.psm1 index 0eeb753..770fb1e 100644 --- a/lib/core/windows/Install-IcingaSecurity.psm1 +++ b/lib/core/windows/Install-IcingaSecurity.psm1 @@ -12,6 +12,11 @@ function Install-IcingaSecurity() return; } + if ((Test-AdministrativeShell) -eq $FALSE) { + Write-IcingaConsoleError -Message 'This command can only be executed from an administrative shell'; + return; + } + # Max length for the user name if ($IcingaUser.Length -gt 20) { Write-IcingaConsoleError 'The specified user name "{0}" is too long. The maximum character limit is 20 digits.' -Objects $IcingaUser;