diff --git a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs
index 543c4126bb..3f429b20b8 100644
--- a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs
+++ b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs
@@ -652,7 +652,11 @@ namespace Microsoft.PowerShell.Commands
else if (Directory.Exists(rootedPath))
{
// Load the latest valid version if it is a multi-version module directory
- foundModule = LoadUsingMultiVersionModuleBase(rootedPath, importModuleOptions, out found);
+ foundModule = LoadUsingMultiVersionModuleBase(rootedPath,
+ ManifestProcessingFlags.LoadElements |
+ ManifestProcessingFlags.WriteErrors |
+ ManifestProcessingFlags.NullOnFirstError,
+ importModuleOptions, out found);
if (!found)
{
diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
index 5bf3efbac5..4aa04d1f58 100644
--- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
+++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
@@ -388,7 +388,7 @@ namespace Microsoft.PowerShell.Commands
string qualifiedPath = Path.Combine(path, fileBaseName);
// Load the latest valid version if it is a multi-version module directory
- module = LoadUsingMultiVersionModuleBase(qualifiedPath, options, out found);
+ module = LoadUsingMultiVersionModuleBase(qualifiedPath, manifestProcessingFlags, options, out found);
if (!found)
{
@@ -432,10 +432,11 @@ namespace Microsoft.PowerShell.Commands
/// Loads the latest valid version if moduleBase is a multi-versioned module directory
///
/// module directory path
+ /// The flag that indicate manifest processing option
/// The set of options that are used while importing a module
/// True if a module was found
///
- internal PSModuleInfo LoadUsingMultiVersionModuleBase(string moduleBase, ImportModuleOptions importModuleOptions, out bool found)
+ internal PSModuleInfo LoadUsingMultiVersionModuleBase(string moduleBase, ManifestProcessingFlags manifestProcessingFlags, ImportModuleOptions importModuleOptions, out bool found)
{
PSModuleInfo foundModule = null;
found = false;
@@ -465,9 +466,7 @@ namespace Microsoft.PowerShell.Commands
null,
this.BasePrefix, /*SessionState*/ null,
importModuleOptions,
- ManifestProcessingFlags.LoadElements |
- ManifestProcessingFlags.WriteErrors |
- ManifestProcessingFlags.NullOnFirstError,
+ manifestProcessingFlags,
out found);
if (found)
{
diff --git a/src/System.Management.Automation/engine/Modules/TestModuleManifestCommand.cs b/src/System.Management.Automation/engine/Modules/TestModuleManifestCommand.cs
index f3ade92282..50fd817bd9 100644
--- a/src/System.Management.Automation/engine/Modules/TestModuleManifestCommand.cs
+++ b/src/System.Management.Automation/engine/Modules/TestModuleManifestCommand.cs
@@ -175,7 +175,7 @@ namespace Microsoft.PowerShell.Commands
{
foreach (ModuleSpecification requiredModule in requiredModules)
{
- var modules = GetModule(new[] { requiredModule.Name }, true, true);
+ var modules = GetModule(new[] { requiredModule.Name }, false, true);
if (modules.Count == 0)
{
string errorMsg = StringUtil.Format(Modules.InvalidRequiredModulesinModuleManifest, requiredModule.Name, filePath);