2021-08-06 12:12:27 -04:00
|
|
|
function Update-IcingaServiceUser()
|
|
|
|
|
{
|
|
|
|
|
$IcingaUser = Get-IcingaPowerShellConfig -Path 'Framework.Icinga.ServiceUser';
|
|
|
|
|
|
|
|
|
|
if ([string]::IsNullOrEmpty($IcingaUser)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((Test-IcingaManagedUser -IcingaUser $IcingaUser) -eq $FALSE) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$SID = Get-IcingaUserSID -User $IcingaUser;
|
2021-09-09 09:46:08 -04:00
|
|
|
$UserConfig = Get-IcingaWindowsInformation -Class 'Win32_UserAccount' -Filter ([string]::Format("SID = '{0}'", $SID));
|
2021-08-06 12:12:27 -04:00
|
|
|
$User = New-IcingaWindowsUser -IcingaUser $UserConfig.Name;
|
|
|
|
|
|
|
|
|
|
Set-IcingaServiceUser -User $IcingaUser -Password $Global:Icinga.ServiceUserPassword -Service 'icinga2' | Out-Null;
|
|
|
|
|
Set-IcingaServiceUser -User $IcingaUser -Password $Global:Icinga.ServiceUserPassword -Service 'icingapowershell' | Out-Null;
|
|
|
|
|
|
|
|
|
|
Restart-IcingaService 'icinga2';
|
|
|
|
|
Restart-IcingaWindowsService;
|
|
|
|
|
}
|