Bird
0
0

You want to create a module that automatically loads when a user runs Get-Data. Which file should you create to define this function and enable auto-loading?

hard📝 Application Q8 of 15
PowerShell - Modules and Script Organization
You want to create a module that automatically loads when a user runs Get-Data. Which file should you create to define this function and enable auto-loading?
ACreate a file named Get-Data.psm1 inside a folder named Get-DataModule
BCreate a file named Get-Data.ps1 in any folder
CCreate a file named Get-Data.psm1 inside a folder named Get-Data
DCreate a file named Get-DataModule.psm1 inside a folder named Get-Data
Step-by-Step Solution
Solution:
  1. Step 1: Understand module auto-loading rules

    PowerShell auto-loads modules when function name matches module folder and file.
  2. Step 2: Match function name with module folder and file

    Function Get-Data requires a module folder named Get-Data with Get-Data.psm1 inside.
  3. Final Answer:

    Create a file named Get-Data.psm1 inside a folder named Get-Data -> Option C
  4. Quick Check:

    Module folder and file name must match function for auto-load [OK]
Quick Trick: Module folder and file name must match function name [OK]
Common Mistakes:
  • Using .ps1 instead of .psm1
  • Mismatching folder and file names
  • Adding extra suffixes to folder name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes