Adds service exclude and service exit code data fetching

This commit is contained in:
Christian Stein 2020-02-18 12:27:47 +01:00
parent 90a8fab9cb
commit 9e52d16a3d

View file

@ -1,7 +1,8 @@
function Get-IcingaServices()
{
param (
[array]$Service
[array]$Service,
[array]$Exclude = @()
);
$ServiceInformation = Get-Service -Name $Service -ErrorAction SilentlyContinue;
@ -25,6 +26,10 @@ function Get-IcingaServices()
[array]$DependingServices = $null;
[string]$ServiceUser = '';
if ($Exclude -contains $service.ServiceName) {
continue;
}
foreach ($wmiService in $ServiceWmiInfo) {
if ($wmiService.Name -eq $service.ServiceName) {
$ServiceUser = $wmiService.StartName;
@ -77,6 +82,7 @@ function Get-IcingaServices()
'value' = $service.StartType;
};
'ServiceUser' = $ServiceUser;
'ExitCode' = [int]$service.ExitCode;
}
}
);