From 9e52d16a3d884894aafdc8e888be49fb7dbc9b16 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Tue, 18 Feb 2020 12:27:47 +0100 Subject: [PATCH] Adds service exclude and service exit code data fetching --- lib/core/tools/Get-IcingaServices.psm1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/core/tools/Get-IcingaServices.psm1 b/lib/core/tools/Get-IcingaServices.psm1 index a6e5a0f..4523f9e 100644 --- a/lib/core/tools/Get-IcingaServices.psm1 +++ b/lib/core/tools/Get-IcingaServices.psm1 @@ -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; } } );