From 00c3d67967de71f92cb5cba2c440354d16d3ee26 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Fri, 26 May 2023 14:17:26 +0200 Subject: [PATCH] Adds support to provide user and domain with @ separated --- doc/100-General/10-Changelog.md | 3 +++ lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index af25974..9e5a604 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -19,6 +19,9 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#617](https://github.com/Icinga/icinga-powershell-framework/issues/617) Fixes failing calls for plugins which use a switch argument like `-NoPerfData`, which is followed directly by the `-ThresholdInterval` argument * [#621](https://github.com/Icinga/icinga-powershell-framework/pull/621) Fixes `-ThresholdInterval` key detection on newer systems +### Enhancements + +* [#623](https://github.com/Icinga/icinga-powershell-framework/issues/623) Adds support to provide the Icinga service user written as `user@domain` ### Enhancements diff --git a/lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 b/lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 index 04229e9..8a8696a 100644 --- a/lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 +++ b/lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 @@ -16,7 +16,10 @@ function Set-IcingaServiceUser() return $FALSE; } - if ($User.Contains('\') -eq $FALSE) { + if ($User.Contains('@')) { + $UserData = $User.Split('@'); + $User = [string]::Format('{0}\{1}', $UserData[1], $UserData[0]); + } elseif ($User.Contains('\') -eq $FALSE) { $User = [string]::Format('.\{0}', $User); }