mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added Service User to Service provider for each service
This commit is contained in:
parent
bbaca8d45b
commit
95cfaf4638
1 changed files with 32 additions and 12 deletions
|
|
@ -5,6 +5,13 @@ function Get-IcingaServices()
|
|||
)
|
||||
|
||||
$ServiceInformation = Get-Service -Name $Service -ErrorAction SilentlyContinue;
|
||||
$ServiceWmiInfo = $null;
|
||||
|
||||
if ($Service.Count -eq 0) {
|
||||
$ServiceWmiInfo = Get-WmiObject Win32_Service;
|
||||
} else {
|
||||
$ServiceWmiInfo = Get-WmiObject -Class Win32_Service | Where-Object { $Service -Contains $_.Name } | Select-Object StartName, Name;
|
||||
}
|
||||
|
||||
if ($null -eq $ServiceInformation) {
|
||||
return $null;
|
||||
|
|
@ -16,16 +23,28 @@ function Get-IcingaServices()
|
|||
|
||||
[array]$DependentServices = $null;
|
||||
[array]$DependingServices = $null;
|
||||
[string]$ServiceUser = '';
|
||||
|
||||
foreach ($wmiService in $ServiceWmiInfo) {
|
||||
if ($wmiService.Name -eq $service.ServiceName) {
|
||||
$ServiceUser = $wmiService.StartName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#Dependent / Child
|
||||
foreach ($dependency in $service.DependentServices) {
|
||||
if ($null -eq $DependentServices) { $DependentServices = @(); }
|
||||
if ($null -eq $DependentServices) {
|
||||
$DependentServices = @();
|
||||
}
|
||||
$DependentServices += $dependency.Name;
|
||||
}
|
||||
|
||||
#Depends / Parent
|
||||
foreach ($dependency in $service.ServicesDependedOn) {
|
||||
if ($null -eq $DependingServices) { $DependingServices = @(); }
|
||||
if ($null -eq $DependingServices) {
|
||||
$DependingServices = @();
|
||||
}
|
||||
$DependingServices += $dependency.Name;
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +76,7 @@ function Get-IcingaServices()
|
|||
'raw' = [int]$service.StartType;
|
||||
'value' = $service.StartType;
|
||||
};
|
||||
'ServiceUser' = $ServiceUser;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue