Skip to content

Commit da9819d

Browse files
committed
Fixes module not loaded exception
1 parent 8d91b69 commit da9819d

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

doc/100-General/10-Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1515

1616
* [#375](https://github.com/Icinga/icinga-powershell-framework/pull/375) Fixes exception on last message printed during `Uninstall-IcingaForWindows`, because the prior used function is no longer present at this point
1717
* [#376](https://github.com/Icinga/icinga-powershell-framework/pull/376) Fixes IMC error handling on invalid JSON for installation command/file
18+
* [#377](https://github.com/Icinga/icinga-powershell-framework/issues/377) Fixes overhead for testing of modules being loaded, which returned invalid path values and wrong exceptions, which was unnecessary in first place
1819
* [#381](https://github.com/Icinga/icinga-powershell-framework/issues/381) Fixes Repository Hash generator for new repositories, which always returned the same hash regardless of the files inside
1920

2021
### Enhancements

lib/icinga/exception/Exit-IcingaPluginNotInstalled.psm1

-18
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,6 @@ function Exit-IcingaPluginNotInstalled()
2727
[string]$Command
2828
);
2929

30-
$PowerShellModule = Get-Module 'icinga-powershell-*' -ListAvailable |
31-
ForEach-Object {
32-
foreach ($cmd in $_.ExportedCommands.Values) {
33-
if ($Command.ToLower() -eq $cmd.Name.ToLower()) {
34-
return $cmd.Path;
35-
}
36-
}
37-
}
38-
39-
if ([string]::IsNullOrEmpty($PowerShellModule) -eq $FALSE) {
40-
try {
41-
Import-Module $PowerShellModule -ErrorAction Stop;
42-
} catch {
43-
$ExMsg = $_.Exception.Message;
44-
Exit-IcingaThrowException -CustomMessage 'Module not loaded' -ExceptionType 'Configuration' -ExceptionThrown $ExMsg -Force;
45-
}
46-
}
47-
4830
if ([string]::IsNullOrEmpty($Command)) {
4931
Exit-IcingaThrowException -CustomMessage 'Null-Command' -ExceptionType 'Configuration' -ExceptionThrown $IcingaExceptions.Configuration.PluginNotAssigned -Force;
5032
}

lib/icinga/exception/Icinga_IcingaExceptionEnums.psm1

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
};
3535

3636
[hashtable]$Configuration = @{
37-
PluginArgumentConflict = 'Your plugin argument configuration is causing a conflict. Mostly this error is caused by missmatching configurations by enabling multiple switch arguments which are resulting in a conflicting configuration for the plugin.';
37+
PluginArgumentConflict = 'Your plugin argument configuration is causing a conflict. Mostly this error is caused by mismatching configurations by enabling multiple switch arguments which are resulting in a conflicting configuration for the plugin.';
3838
PluginArgumentMissing = 'Your plugin argument configuration is missing mandatory arguments. This error is caused when mandatory or required arguments are missing from a plugin call and the operation is unable to process without them.';
39-
PluginNotInstalled = 'The plugin assigned to this service check seems not to be installed on this machine. Please review your service check configuration for spelling errors and check if the plugin is installed and executable on this machine by PowerShell.';
39+
PluginNotInstalled = 'The plugin assigned to this service check seems not to be installed on this machine. Please review your service check configuration for spelling errors and check if the plugin is installed and executable on this machine by PowerShell. You can ensure modules are available by manually importing them by their name with the following commands: Import-Module -Name "module name" -Force; Import-Module -Name "module name" -Global -Force;';
4040
PluginNotAssigned = 'Your check for this service could not be processed because it seems like no valid Cmdlet was assigned to the check command. Please review your check command to ensure that a valid Cmdlet is assigned and executed by a PowerShell call.';
4141
EventLogNotInstalled = 'Your Icinga PowerShell Framework has been executed by an unprivileged user before it was properly installed. The Windows EventLog application could not be registered because the current user has insufficient permissions. Please log into the machine and run "Use-Icinga" once from an administrative shell to complete the setup process. Once done this error should vanish.';
4242
PerfCounterCategoryMissing = 'The specified Performance Counter category was not found on this system. This could either be a configuration error on your local Windows machine or a wrong usage of the plugin. Please check on different Windows machines if this issue persis. In case it only occurs on certain machines it is likely that the counter is simply not present and the plugin can not be processed.';

0 commit comments

Comments
 (0)