Bird
0
0

You try to import a script module with the command Import-Module MyModule.psm1 but get an error saying the module is not found. What is the most likely cause?

medium📝 Debug Q6 of 15
PowerShell - Modules and Script Organization
You try to import a script module with the command Import-Module MyModule.psm1 but get an error saying the module is not found. What is the most likely cause?
AScript modules cannot be imported with Import-Module.
BThe module file is not in the current directory or module path.
CThe file extension should be .dll for script modules.
DPowerShell does not support .psm1 files.
Step-by-Step Solution
Solution:
  1. Step 1: Check module file location

    Import-Module requires the module file to be in the current directory or in a path listed in $env:PSModulePath.
  2. Step 2: Understand error cause

    If the file is not found, PowerShell throws an error about missing module.
  3. Final Answer:

    The module file is not in the current directory or module path. -> Option B
  4. Quick Check:

    Module not found error cause = A [OK]
Quick Trick: Ensure module file is in current or module path before importing. [OK]
Common Mistakes:
  • Assuming Import-Module can't load script modules
  • Confusing file extensions
  • Ignoring module path environment variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes