mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Adds support for generic call of wildcard functions for fetching multi data
This commit is contained in:
parent
935c497a7d
commit
2e225e1ce5
1 changed files with 30 additions and 0 deletions
30
lib/core/framework/Invoke-IcingaNamespaceCmdlets.psm1
Normal file
30
lib/core/framework/Invoke-IcingaNamespaceCmdlets.psm1
Normal 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;
|
||||
}
|
||||
Loading…
Reference in a new issue