icinga-powershell-framework/lib/daemon/Register-IcingaBackgroundDaemon.psm1
2019-10-22 19:53:50 +02:00

22 lines
831 B
PowerShell

function Register-IcingaBackgroundDaemon()
{
param(
[string]$Command,
[hashtable]$Arguments
);
if ([string]::IsNullOrEmpty($Command)) {
throw 'Please specify a Cmdlet to run as Background Daemon';
}
if (-Not (Test-IcingaFunction $Command)) {
throw ([string]::Format('The Cmdlet "{0}" is not available in your session. Please restart the session and try again or verify your input', $Command));
}
$Path = [string]::Format('BackgroundDaemon.EnabledDaemons.{0}', $Command);
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.Command', $Path)) -Value $Command;
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.Arguments', $Path)) -Value $Arguments;
Write-Host ([string]::Format('Background daemon Cmdlet "{0}" has been configured', $Command));
}