2020-03-25 12:51:53 -04:00
|
|
|
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;
|
2020-03-25 12:51:53 -04:00
|
|
|
Import-Module $Cmdlet.Module.Path -WarningAction SilentlyContinue -ErrorAction Stop;
|
|
|
|
|
|
2021-08-17 03:22:05 -04:00
|
|
|
$Content = (& $CommandName);
|
2020-08-04 08:48:32 -04:00
|
|
|
Add-IcingaHashtableItem `
|
|
|
|
|
-Hashtable $CommandConfig `
|
|
|
|
|
-Key $Cmdlet.Name `
|
|
|
|
|
-Value $Content | Out-Null;
|
2020-03-25 12:51:53 -04:00
|
|
|
} catch {
|
|
|
|
|
# TODO: Add event log logging on exceptions
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $CommandConfig;
|
|
|
|
|
}
|