Hint: Import module first, then call function for output [OK]
Common Mistakes:
Forgetting to import the module before calling function
Expecting 'Hello World!' without comma
Typos in function name causing errors
4. You wrote a module file Utils.psm1 with a function but when you run Import-Module .\Utils.psm1, you get an error: "Cannot load module because of a syntax error." What is a common cause?
medium
A. The module file has a missing closing brace '}' in the function
B. The module file is saved with .ps1 extension
C. You forgot to run PowerShell as administrator
D. The function name is too long
Solution
Step 1: Identify syntax error causes in module files
Missing closing braces in functions cause syntax errors preventing module import.
Step 2: Evaluate other options
.ps1 extension is wrong but causes different error; admin rights or function name length do not cause syntax errors.
Final Answer:
The module file has a missing closing brace '}' in the function -> Option A
Quick Check:
Syntax error = missing brace [OK]
Hint: Check braces and syntax carefully in .psm1 files [OK]
Common Mistakes:
Confusing file extension errors with syntax errors
Assuming admin rights fix syntax errors
Ignoring missing braces or parentheses
5. You want to create a PowerShell module that contains two functions: Get-DateInfo and Get-UserInfo. Which is the correct way to organize and import these functions?
hard
A. Create separate .ps1 files for each function and run them directly
B. Put both functions in a single .psm1 file and import it with Import-Module
C. Put both functions in a .psm1 file but call them without importing the module
D. Create a .dll file containing the functions and import it with Import-Module
Solution
Step 1: Understand module organization
PowerShell modules typically group related functions in one .psm1 file for easy import.
Step 2: Evaluate import method
Import-Module loads the .psm1 file, making all functions available; running .ps1 files directly is not modular.
Final Answer:
Put both functions in a single .psm1 file and import it with Import-Module -> Option B
Quick Check:
Functions grouped in .psm1, import module [OK]
Hint: Group functions in one .psm1 file, then import [OK]
Common Mistakes:
Running .ps1 files instead of importing modules
Calling functions without importing module first
Trying to use .dll files without compiling
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.