mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
25 lines
792 B
PowerShell
25 lines
792 B
PowerShell
function Get-IcingaServiceUser()
|
|
{
|
|
$IcingaService = $Global:Icinga.Protected.Environment.'Icinga Service';
|
|
$IfWService = $Global:Icinga.Protected.Environment.'PowerShell Service';
|
|
# Default User
|
|
$ServiceUser = 'NT Authority\NetworkService';
|
|
|
|
if ($null -eq $IcingaService -Or $null -eq $IfWService) {
|
|
Set-IcingaServiceEnvironment;
|
|
}
|
|
|
|
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';
|
|
}
|
|
}
|
|
|
|
return $ServiceUser;
|
|
}
|