icinga-powershell-framework/lib/core/framework/Invoke-IcingaNamespaceCmdlets.psm1
Lord Hepipud 4ef55bddb4 Fixes lots of code styling, spelling and script analyzer
Disabling UseConsistentIndentation because it is not
properly working for multi-line commands with arguments
and array/hashtable objects
2022-01-14 22:26:53 +01:00

30 lines
762 B
PowerShell

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 {
$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;
}