mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
25 lines
1 KiB
PowerShell
25 lines
1 KiB
PowerShell
|
|
function Set-IcingaForWindowsServiceJEAProfile()
|
||
|
|
{
|
||
|
|
[string]$JeaProfile = Get-IcingaJEAContext;
|
||
|
|
$IcingaForWindowsService = Get-IcingaForWindowsServiceData;
|
||
|
|
|
||
|
|
if ([string]::IsNullOrEmpty($IcingaForWindowsService.FullPath) -Or (Test-Path $IcingaForWindowsService.FullPath) -eq $FALSE) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
[string]$PreparedServicePath = [string]::Format(
|
||
|
|
'\"{0}\" \"{1}\" \"{2}\"',
|
||
|
|
$IcingaForWindowsService.FullPath,
|
||
|
|
(Get-IcingaPowerShellModuleFile),
|
||
|
|
$JeaProfile
|
||
|
|
);
|
||
|
|
|
||
|
|
$Result = Start-IcingaProcess -Executable 'sc.exe' -Arguments ([string]::Format('config icingapowershell binPath= "{0}"', $PreparedServicePath));
|
||
|
|
|
||
|
|
if ($Result.ExitCode -ne 0) {
|
||
|
|
Write-IcingaConsoleError 'Failed to update Icinga for Windows service for JEA profile "{0}": {1}{2}' -Objects $JeaProfile, $ResolveStatus.Message, $ResolveStatus.Error;
|
||
|
|
} else {
|
||
|
|
Write-IcingaConsoleNotice 'Icinga for Windows service JEA handling has been configured successfully to profile "{0}"' -Objects $JeaProfile;
|
||
|
|
}
|
||
|
|
}
|