Fixes JEA error on no modules installed and output

This commit is contained in:
Lord Hepipud 2022-01-27 21:56:19 +01:00
parent 9bcd2210e7
commit 210862e683
3 changed files with 16 additions and 3 deletions

View file

@ -32,6 +32,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#441](https://github.com/Icinga/icinga-powershell-framework/pull/441) Fixes an exception while loading the Framework, caused by a race condition for missing environment variables which are accessed by some plugins before the Framework is loaded properly
* [#446](https://github.com/Icinga/icinga-powershell-framework/pull/446) Fixes Icinga for Windows progress preference, which sometimes caused UI glitches
* [#449](https://github.com/Icinga/icinga-powershell-framework/pull/449) Fixes unhandled exception while importing modules during `Install-IcingaComponent` process, because of possible missing dependencies
* [#451](https://github.com/Icinga/icinga-powershell-framework/pull/451) Fixes PowerShell being unable to enter JEA context if only the Framework is installed and removes the `|` from plugin output, in case a JEA error is thrown that check commands are not present
### Enhancements

View file

@ -154,6 +154,13 @@ function Get-IcingaJEAConfiguration()
-CmdName 'Add-IcingaForWindowsDaemon' `
-CmdType 'Function';
# Fixes error if only the Icinga PowerShell Framework is installed, which then causes JEA to fail entirely because of this missing Cmdlet
$UsedCmdlets = Get-IcingaCommandDependency `
-DependencyList $DependencyList `
-CompiledList $UsedCmdlets `
-CmdName 'Select-Object' `
-CmdType 'Cmdlet';
# Finally loop through all commands again and build our JEA command list
$DeserializedFile = Read-IcingaPowerShellModuleFile -FileContent $ModuleContent;
[array]$JeaCmds = $DeserializedFile.CommandList + $DeserializedFile.FunctionList;

View file

@ -7,10 +7,15 @@ function Write-IcingaPluginResult()
[string]$CheckResult = $PluginOutput;
if ($PluginPerfData -ne 0) {
$CheckResult += "`n`r| ";
if ($PluginPerfData.Count -ne 0) {
[string]$PerfDataContent = '';
foreach ($PerfData in $PluginPerfData) {
$CheckResult += $PerfData;
$PerfDataContent += $PerfData;
}
if ([string]::IsNullOrEmpty($PerfDataContent) -eq $FALSE) {
$CheckResult += "`n`r| ";
$CheckResult += $PerfDataContent;
}
}