mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
23 lines
852 B
PowerShell
23 lines
852 B
PowerShell
|
|
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;
|
||
|
|
$UserConfig = Get-IcingaWindowsInformation -Class 'Win32_UserAccount' | Where-Object { $_.SID -eq $SID };
|
||
|
|
$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;
|
||
|
|
}
|