Skip to content

Commit 9907cc8

Browse files
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 <[email protected]>
1 parent af1e5b7 commit 9907cc8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

jobs/GetWindowsService.ps1

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ try {
1919
$SvcData = Get-IcingaServices "$ServiceName" -ErrorAction Stop;
2020

2121
if ($null -ne $SvcData) {
22-
$ServiceData.Status = [string]$SvcData."$ServiceName".configuration.Status.value;
23-
$ServiceData.User = [string]$SvcData."$ServiceName".configuration.ServiceUser;
24-
$ServiceData.ServicePath = [string]$SvcData."$ServiceName".configuration.ServicePath;
25-
$ServiceData.Name = $SvcData."$ServiceName".metadata.ServiceName;
26-
$ServiceData.DisplayName = $SvcData."$ServiceName".metadata.DisplayName;
22+
$ServiceConfig = $SvcData."$ServiceName".configuration;
23+
$ServiceMeta = $SvcData."$ServiceName".metadata;
24+
$ServiceInfo.Status = [string]$ServiceConfig.Status.value;
25+
$ServiceInfo.User = [string]$ServiceConfig.ServiceUser;
26+
$ServiceInfo.ServicePath = [string]$ServiceConfig.ServicePath;
27+
$ServiceInfo.Name = $ServiceMeta.ServiceName;
28+
$ServiceInfo.DisplayName = $ServiceMeta.DisplayName;
2729
$ServiceData.Present = $TRUE;
2830
}
2931
} catch {

0 commit comments

Comments
 (0)