Adds support for generic call of wildcard functions for fetching multi data

This commit is contained in:
Christian Stein 2020-03-25 17:51:53 +01:00
parent 935c497a7d
commit 2e225e1ce5

View file

@ -0,0 +1,30 @@
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 {
$CmmandName = $Cmdlet.Name;
Import-Module $Cmdlet.Module.Path -WarningAction SilentlyContinue -ErrorAction Stop;
$Content = (& $CmmandName);
Add-IcingaHashtableItem -Hashtable $CommandConfig `
-Key $Cmdlet.Name `
-Value $Content | Out-Null;
} catch {
# TODO: Add event log logging on exceptions
}
}
return $CommandConfig;
}