Bird
0
0

You created a module file named Helpers.psm1 but when running Import-Module Helpers, you receive an error stating the module cannot be found. What is a likely cause?

medium📝 Debug Q6 of 15
PowerShell - Modules and Script Organization
You created a module file named Helpers.psm1 but when running Import-Module Helpers, you receive an error stating the module cannot be found. What is a likely cause?
AThe module file has a .ps1 extension instead of .psm1
BThe module file is not located in a directory listed in $env:PSModulePath
CThe module file contains no functions
DThe module file is missing a manifest (.psd1) file
Step-by-Step Solution
Solution:
  1. Step 1: Check module location

    PowerShell searches for modules in paths defined by $env:PSModulePath.
  2. Step 2: Identify cause of error

    If the module file is not in one of these paths or the current directory, Import-Module will fail.
  3. Final Answer:

    The module file is not located in a directory listed in $env:PSModulePath -> Option B
  4. Quick Check:

    Module must be in PSModulePath or imported with full path [OK]
Quick Trick: Modules must be in PSModulePath or imported with full path [OK]
Common Mistakes:
  • Assuming .psd1 manifest is mandatory for all modules
  • Confusing .ps1 script files with module files
  • Thinking empty modules cause import errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes