icinga-powershell-framework/lib/core/framework/Invoke-IcingaNamespaceCmdlets.psm1

31 lines
761 B
PowerShell
Raw Normal View History

function Invoke-IcingaNamespaceCmdlets()
{
param (
[string]$Command
);
[Hashtable]$CommandConfig = @{};
if ($Command.Contains('*') -eq $FALSE) {
$Command = [string]::Format('{0}*', $Command);
}
$CommandList = Get-Command $Command;
foreach ($Cmdlet in $CommandList) {
try {
2021-08-17 03:22:05 -04:00
$CommandName = $Cmdlet.Name;
$Content = (& $CommandName);
Add-IcingaHashtableItem `
-Hashtable $CommandConfig `
-Key $Cmdlet.Name `
-Value $Content | Out-Null;
} catch {
Write-IcingaEventMessage -EventId 1103 -Namespace 'Framework' -Objects $CommandName, $_.Exception.Message;
}
}
return $CommandConfig;
}