2019-09-29 12:25:40 -04:00
|
|
|
function Get-IcingaServiceUser()
|
|
|
|
|
{
|
2024-03-14 12:16:09 -04:00
|
|
|
$IcingaService = $Global:Icinga.Protected.Environment.'Icinga Service';
|
|
|
|
|
$IfWService = $Global:Icinga.Protected.Environment.'PowerShell Service';
|
|
|
|
|
# Default User
|
|
|
|
|
$ServiceUser = 'NT Authority\NetworkService';
|
2019-09-29 12:25:40 -04:00
|
|
|
|
2024-03-14 12:16:09 -04:00
|
|
|
if ($null -eq $IcingaService -Or $null -eq $IfWService) {
|
|
|
|
|
Set-IcingaServiceEnvironment;
|
|
|
|
|
}
|
2020-03-11 08:01:54 -04:00
|
|
|
|
2024-03-14 12:16:09 -04:00
|
|
|
if ($IcingaService.Present) {
|
|
|
|
|
$ServiceUser = $IcingaService.User.Replace('.\', '');
|
|
|
|
|
if ($ServiceUser -eq 'LocalSystem') {
|
|
|
|
|
return 'NT Authority\SYSTEM';
|
|
|
|
|
}
|
|
|
|
|
} elseif ($IfWService.Present) {
|
|
|
|
|
$ServiceUser = $IfWService.User.Replace('.\', '');
|
|
|
|
|
if ($ServiceUser -eq 'LocalSystem') {
|
|
|
|
|
return 'NT Authority\SYSTEM';
|
|
|
|
|
}
|
2020-03-11 08:01:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $ServiceUser;
|
2019-09-29 12:25:40 -04:00
|
|
|
}
|