icinga-powershell-framework/lib/icinga/plugin/Exit-IcingaExecutePlugin.psm1

24 lines
652 B
PowerShell
Raw Normal View History

function Exit-IcingaExecutePlugin()
{
param (
[string]$Command = ''
);
Invoke-IcingaInternalServiceCall -Command $Command -Arguments $args;
try {
# Load the entire framework now, as we require to execute plugins locally
if ($null -eq $global:IcingaDaemonData) {
Use-Icinga;
}
Exit-IcingaPluginNotInstalled -Command $Command;
exit (& $Command @args);
} catch {
$ExMsg = $_.Exception.Message;
Write-IcingaConsolePlain '[UNKNOWN]: {0}{1}{1}CheckCommand: {2}{1}Arguments: {3}' -Objects $ExMsg, (New-IcingaNewLine), $Command, $args;
exit 3;
}
}