icinga-powershell-framework/lib/core/windows/Update-IcingaServiceUser.psm1

22 lines
750 B
PowerShell
Raw Normal View History

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;
}
$UserConfig = Get-IcingaWindowsUserConfig -UserName $IcingaUser;
$User = New-IcingaWindowsUser -IcingaUser $UserConfig.Name;
2021-08-06 12:12:27 -04:00
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;
}