Skip to content

Commit 9e52d16

Browse files
committed
Adds service exclude and service exit code data fetching
1 parent 90a8fab commit 9e52d16

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/core/tools/Get-IcingaServices.psm1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function Get-IcingaServices()
22
{
33
param (
4-
[array]$Service
4+
[array]$Service,
5+
[array]$Exclude = @()
56
);
67

78
$ServiceInformation = Get-Service -Name $Service -ErrorAction SilentlyContinue;
@@ -25,6 +26,10 @@ function Get-IcingaServices()
2526
[array]$DependingServices = $null;
2627
[string]$ServiceUser = '';
2728

29+
if ($Exclude -contains $service.ServiceName) {
30+
continue;
31+
}
32+
2833
foreach ($wmiService in $ServiceWmiInfo) {
2934
if ($wmiService.Name -eq $service.ServiceName) {
3035
$ServiceUser = $wmiService.StartName;
@@ -77,6 +82,7 @@ function Get-IcingaServices()
7782
'value' = $service.StartType;
7883
};
7984
'ServiceUser' = $ServiceUser;
85+
'ExitCode' = [int]$service.ExitCode;
8086
}
8187
}
8288
);

0 commit comments

Comments
 (0)