Improved Directory module loading

This commit is contained in:
Lord Hepipud 2019-07-23 09:17:11 +02:00
parent fb6267b051
commit ca827502c3

View file

@ -43,14 +43,15 @@ function Import-IcingaLib()
[string]$modulePath = $_.FullName;
$moduleName = $_.Name.Replace('.psm1', '');
if ($ForceReload) {
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;
}
}
} else {
$module = $module.Replace('.psm1', ''); # Cut possible .psm1 ending
$moduleName = $module.Split('\')[-1]; # Get the last element