Skip to content

Commit bec322b

Browse files
committed
Fixes missing loading for IfW modules
1 parent bc70537 commit bec322b

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

doc/100-General/10-Changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ documentation before upgrading to a new release.
77

88
Released closed milestones can be found on [GitHub](https://github.com/Icinga/icinga-powershell-framework/milestones?state=closed).
99

10+
## 1.9.1 (2022-05-13)
11+
12+
### Bugfixes
13+
14+
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/24?closed=1)
15+
16+
* [#519](https://github.com/Icinga/icinga-powershell-framework/pull/519) Fixes missing loading of Icinga for Windows modules, which is required to ensure an Icinga for Windows environment is providing all commands and variables to a session, allowing other modules to access these information
17+
1018
## 1.9.0 (2022-05-03)
1119

1220
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/20?closed=1)

icinga-powershell-framework.psm1

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ function Use-Icinga()
2828
$Global:Icinga.Protected.Minimal = $TRUE;
2929
}
3030

31-
# Ensure we autoload the Icinga Plugin collection, provided by the external
32-
# module 'icinga-powershell-plugins'
33-
if (Get-Command 'Use-IcingaPlugins' -ErrorAction SilentlyContinue) {
34-
Use-IcingaPlugins;
35-
}
31+
# Ensure we autoload Icinga for Windows modules into this session
32+
Import-IcingaForWindowsModulesInSession;
3633

3734
if ($Daemon) {
3835
$Global:Icinga.Protected.RunAsDaemon = $TRUE;
@@ -64,6 +61,29 @@ function Use-Icinga()
6461
}
6562
}
6663

64+
function Import-IcingaForWindowsModulesInSession()
65+
{
66+
$CommandList = Get-Command 'Import-IcingaPowerShellComponent*';
67+
68+
foreach ($entry in $CommandList) {
69+
$ModuleName = $entry.Module.Name;
70+
$ModulePath = $entry.Module.Path;
71+
$RootPath = $ModulePath.Substring(0, $ModulePath.IndexOf($ModuleName));
72+
$Command = $entry.Name;
73+
74+
if ($RootPath.ToLower() -ne (Get-IcingaForWindowsRootPath).ToLower()) {
75+
continue;
76+
}
77+
78+
if ([string]::IsNullOrEmpty($Command) -Or (Test-IcingaFunction $Command) -eq $FALSE) {
79+
continue;
80+
}
81+
82+
# Execute the command if the module is located at the same location as our Framework
83+
& $Command | Out-Null;
84+
}
85+
}
86+
6787
function Get-IcingaFrameworkCodeCacheFile()
6888
{
6989
return (Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'framework_cache.psm1');

0 commit comments

Comments
 (0)