2019-10-17 16:51:12 -04:00
|
|
|
function Set-IcingaAgentServicePermission()
|
|
|
|
|
{
|
|
|
|
|
if (Test-IcingaAgentServicePermission -Silent) {
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleNotice 'The Icinga Service User already has permission to run as service';
|
2019-10-17 16:51:12 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-23 11:25:23 -05:00
|
|
|
$ServiceUser = Get-IcingaServiceUser;
|
|
|
|
|
$ServiceUserSID = Get-IcingaUserSID $ServiceUser;
|
2019-10-17 16:51:12 -04:00
|
|
|
|
|
|
|
|
if ([string]::IsNullOrEmpty($ServiceUser)) {
|
2020-05-22 10:34:18 -04:00
|
|
|
Write-IcingaTestOutput -Severity 'Failed' -Message 'There is no user assigned to the Icinga 2 service or the service is not yet installed';
|
2019-10-17 16:51:12 -04:00
|
|
|
return $FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-23 11:25:23 -05:00
|
|
|
Update-IcingaWindowsUserPermission -SID $ServiceUserSID;
|
2019-10-17 16:51:12 -04:00
|
|
|
|
2020-08-04 08:48:32 -04:00
|
|
|
Test-IcingaAgentServicePermission | Out-Null;
|
2019-10-17 16:51:12 -04:00
|
|
|
}
|