From 9907cc8e8e4c4fe47208182500f257f8718a5938 Mon Sep 17 00:00:00 2001 From: Angel Roman Date: Thu, 30 Jan 2025 10:48:34 -0500 Subject: [PATCH] Update GetWindowsService.ps1 (#751) * Update GetWindowsService.ps1 Instead of repeatedly accessing $SvcData."$ServiceName", store the object in a local variable for better readability. * Update GetWindowsService.ps1 Fixes code styling --------- Co-authored-by: Lord Hepipud --- jobs/GetWindowsService.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jobs/GetWindowsService.ps1 b/jobs/GetWindowsService.ps1 index c85a699..4ca8735 100644 --- a/jobs/GetWindowsService.ps1 +++ b/jobs/GetWindowsService.ps1 @@ -19,11 +19,13 @@ try { $SvcData = Get-IcingaServices "$ServiceName" -ErrorAction Stop; if ($null -ne $SvcData) { - $ServiceData.Status = [string]$SvcData."$ServiceName".configuration.Status.value; - $ServiceData.User = [string]$SvcData."$ServiceName".configuration.ServiceUser; - $ServiceData.ServicePath = [string]$SvcData."$ServiceName".configuration.ServicePath; - $ServiceData.Name = $SvcData."$ServiceName".metadata.ServiceName; - $ServiceData.DisplayName = $SvcData."$ServiceName".metadata.DisplayName; + $ServiceConfig = $SvcData."$ServiceName".configuration; + $ServiceMeta = $SvcData."$ServiceName".metadata; + $ServiceInfo.Status = [string]$ServiceConfig.Status.value; + $ServiceInfo.User = [string]$ServiceConfig.ServiceUser; + $ServiceInfo.ServicePath = [string]$ServiceConfig.ServicePath; + $ServiceInfo.Name = $ServiceMeta.ServiceName; + $ServiceInfo.DisplayName = $ServiceMeta.DisplayName; $ServiceData.Present = $TRUE; } } catch {