From ca827502c3074c9cd37b5c8f6ab12adf594bff47 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Tue, 23 Jul 2019 09:17:11 +0200 Subject: [PATCH] Improved Directory module loading --- icinga-module-windows.psm1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/icinga-module-windows.psm1 b/icinga-module-windows.psm1 index 97aa99e..b04b78f 100644 --- a/icinga-module-windows.psm1 +++ b/icinga-module-windows.psm1 @@ -43,13 +43,14 @@ function Import-IcingaLib() [string]$modulePath = $_.FullName; $moduleName = $_.Name.Replace('.psm1', ''); - if ($ForceReload) { - if ($ListOfLoadedModules -like "*$moduleName*") { + if ($ListOfLoadedModules -like "*$moduleName*") { + if ($ForceReload) { Remove-Module -Name $moduleName + Import-Module ([string]::Format('{0}', $modulePath)) -Global; } + } else { + Import-Module ([string]::Format('{0}', $modulePath)) -Global; } - - Import-Module ([string]::Format('{0}', $modulePath)) -Global; } } else { $module = $module.Replace('.psm1', ''); # Cut possible .psm1 ending