mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 14:51:19 -05:00
31 lines
1 KiB
PowerShell
31 lines
1 KiB
PowerShell
function Uninstall-IcingaServiceUser()
|
|
{
|
|
param (
|
|
$IcingaUser = 'icinga'
|
|
);
|
|
|
|
if ([string]::IsNullOrEmpty($IcingaUser)) {
|
|
Write-IcingaConsoleError 'The provided user cannot be empty.';
|
|
return;
|
|
}
|
|
|
|
Write-IcingaConsoleNotice 'Uninstalling user "{0}"' -Objects $IcingaUser;
|
|
|
|
Stop-IcingaService 'icinga2';
|
|
Stop-IcingaWindowsService;
|
|
|
|
Set-IcingaPowerShellConfig -Path 'Framework.Icinga.ServiceUser' -Value '';
|
|
|
|
Set-IcingaServiceUser -User 'NT Authority\NetworkService' -Service 'icinga2' | Out-Null;
|
|
Set-IcingaServiceUser -User 'NT Authority\NetworkService' -Service 'icingapowershell' | Out-Null;
|
|
|
|
Set-IcingaUserPermissions -IcingaUser $IcingaUser -Remove;
|
|
|
|
$UserConfig = Remove-IcingaWindowsUser -IcingaUser $IcingaUser;
|
|
Update-IcingaWindowsUserPermission -SID $UserConfig.SID -Remove;
|
|
|
|
Restart-IcingaService 'icinga2';
|
|
Restart-IcingaWindowsService;
|
|
|
|
Write-IcingaConsoleNotice 'User "{0}" including permissions was removed from this host' -Objects $IcingaUser;
|
|
}
|