Bird
Raised Fist0
PowerShellscripting~20 mins

Module manifest (.psd1) in PowerShell - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
PowerShell Module Manifest Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Output of a basic module manifest property
Given this snippet from a PowerShell module manifest (.psd1), what is the output of the command $manifest.Author after importing the manifest as a variable?
PowerShell
@{RootModule = 'MyModule.psm1'; Author = 'Jane Doe'; ModuleVersion = '1.0.0'}
A'Jane Doe'
B'MyModule.psm1'
C'1.0.0'
Dnull
Attempts:
2 left
💡 Hint
Look for the key named 'Author' in the hashtable.
📝 Syntax
intermediate
2:00remaining
Correct syntax for specifying RequiredModules in a .psd1
Which option correctly specifies the RequiredModules key in a PowerShell module manifest to require two modules named 'PSReadLine' and 'Pester' with minimum versions 2.0 and 5.0 respectively?
A@{RequiredModules = @{'PSReadLine'='2.0'; 'Pester'='5.0'}}
B@{RequiredModules = @('PSReadLine', 'Pester')}
C@{RequiredModules = @('PSReadLine:2.0', 'Pester:5.0')}
D@{RequiredModules = @(@{ModuleName='PSReadLine'; ModuleVersion='2.0'}, @{ModuleName='Pester'; ModuleVersion='5.0'})}
Attempts:
2 left
💡 Hint
RequiredModules expects an array of hashtables with ModuleName and ModuleVersion keys.
🔧 Debug
advanced
2:00remaining
Identify the error in this module manifest snippet
This snippet is part of a PowerShell module manifest (.psd1). What error will occur when PowerShell tries to import this manifest?
PowerShell
@{
  RootModule = 'MyModule.psm1'
  Author = 'John Smith'
  ModuleVersion = '1.0.0'
  FunctionsToExport = @('Get-Data', 'Set-Data'
}
ASyntaxError due to missing closing parenthesis in FunctionsToExport array
BRuntime error because RootModule file does not exist
CNo error, manifest imports successfully
DTypeError because FunctionsToExport must be a string, not an array
Attempts:
2 left
💡 Hint
Check the brackets and commas in the FunctionsToExport line.
🚀 Application
advanced
1:30remaining
Determine the number of exported commands from a manifest
Given this module manifest snippet, how many commands will be exported by default when the module is imported?
PowerShell
@{
  RootModule = 'MyModule.psm1'
  FunctionsToExport = @('Get-Item', 'Set-Item')
  CmdletsToExport = @('Invoke-Action')
  AliasesToExport = @()
}
A1
B2
C3
D0
Attempts:
2 left
💡 Hint
Count all functions, cmdlets, and aliases listed for export.
🧠 Conceptual
expert
1:30remaining
Understanding the role of PrivateData in a module manifest
What is the primary purpose of the PrivateData key in a PowerShell module manifest (.psd1)?
ATo list all private functions that should not be exported
BTo store custom data used internally by the module or tools, not processed by PowerShell itself
CTo specify the private variables accessible only within the module
DTo define the private dependencies that are not installed automatically
Attempts:
2 left
💡 Hint
Think about data that is not standard manifest keys but useful for module authors or tools.

Practice

(1/5)
1. What is the primary purpose of a PowerShell module manifest (.psd1)?
easy
A. To store user credentials for the module
B. To execute the module's main script
C. To describe the module's metadata and control its behavior
D. To compile the module into an executable file

Solution

  1. Step 1: Understand what a module manifest is

    A module manifest is a file that contains metadata about the module, such as version, author, and dependencies.
  2. Step 2: Identify the manifest's role

    It controls what parts of the module are visible and required, helping users understand and use the module properly.
  3. Final Answer:

    To describe the module's metadata and control its behavior -> Option C
  4. Quick Check:

    Manifest = metadata and control [OK]
Hint: Manifest files describe modules, not run code [OK]
Common Mistakes:
  • Thinking the manifest runs the module code
  • Confusing manifest with script files
  • Assuming manifest stores credentials
2. Which of the following is the correct syntax to specify the module version in a .psd1 manifest file?
easy
A. 'ModuleVersion' = '1.0.0'
B. ModuleVersion: 1.0.0
C. ModuleVersion = 1.0.0
D. "ModuleVersion" : "1.0.0"

Solution

  1. Step 1: Recall .psd1 file syntax

    A .psd1 file uses a hashtable syntax with key-value pairs, where keys are strings in quotes and values are assigned with '='.
  2. Step 2: Match correct syntax for version

    The correct syntax is a string key in quotes, an equals sign, and the version string in quotes: 'ModuleVersion' = '1.0.0'
  3. Final Answer:

    'ModuleVersion' = '1.0.0' -> Option A
  4. Quick Check:

    Hashtable key-value with '=' and quotes [OK]
Hint: Use quotes and '=' for keys and values in .psd1 [OK]
Common Mistakes:
  • Using colon instead of equals sign
  • Omitting quotes around keys or values
  • Using JSON style syntax
3. Given this snippet from a module manifest (.psd1):
@{
  RootModule = 'MyModule.psm1'
  ModuleVersion = '2.1.0'
  FunctionsToExport = @('Get-Data', 'Set-Data')
}

What will happen when you import this module?
medium
A. Only the functions 'Get-Data' and 'Set-Data' will be available to the user
B. All functions in MyModule.psm1 will be available regardless of FunctionsToExport
C. The module will fail to import due to syntax error
D. The module version will be ignored during import

Solution

  1. Step 1: Understand FunctionsToExport key

    The FunctionsToExport key lists which functions are visible outside the module when imported.
  2. Step 2: Analyze the effect on import

    Only 'Get-Data' and 'Set-Data' will be exported and accessible to users after import.
  3. Final Answer:

    Only the functions 'Get-Data' and 'Set-Data' will be available to the user -> Option A
  4. Quick Check:

    FunctionsToExport limits visible functions [OK]
Hint: FunctionsToExport controls visible functions [OK]
Common Mistakes:
  • Assuming all functions export by default
  • Thinking syntax error exists here
  • Ignoring FunctionsToExport effect
4. You wrote this in your module manifest (.psd1):
@{
  RootModule = 'MyModule.psm1'
  FunctionsToExport = 'Get-Data', 'Set-Data'
}

When importing the module, you get an error. What is the problem?
medium
A. The manifest file must not contain RootModule key
B. RootModule must be a script file, not a module file
C. FunctionsToExport cannot contain more than one function
D. FunctionsToExport should be an array, not a list of strings without @()

Solution

  1. Step 1: Check FunctionsToExport syntax

    FunctionsToExport expects an array of strings, which requires the @() syntax in PowerShell.
  2. Step 2: Identify the error cause

    Writing 'Get-Data', 'Set-Data' without @() is invalid in a hashtable value and causes an error.
  3. Final Answer:

    FunctionsToExport should be an array, not a list of strings without @() -> Option D
  4. Quick Check:

    Use @() for arrays in manifest [OK]
Hint: Use @() to define arrays in .psd1 manifest [OK]
Common Mistakes:
  • Omitting @() for arrays
  • Misunderstanding RootModule usage
  • Assuming single string can list multiple functions
5. You want your PowerShell module to automatically import a required module and only export one function named 'Invoke-Task'. Which manifest entries should you include?
hard
A. @{ RequiredModules = 'HelperModule'; FunctionsToExport = @('Invoke-Task') }
B. @{ RequiredModules = @('HelperModule'); FunctionsToExport = @('Invoke-Task') }
C. @{ RequiredModules = @('HelperModule'); FunctionsToExport = 'Invoke-Task' }
D. @{ RequiredModules = 'HelperModule'; FunctionsToExport = 'Invoke-Task' }

Solution

  1. Step 1: Define RequiredModules correctly

    RequiredModules must be an array of module names, so use @('HelperModule').
  2. Step 2: Define FunctionsToExport correctly

    FunctionsToExport must be an array of function names, so use @('Invoke-Task').
  3. Final Answer:

    @{ RequiredModules = @('HelperModule'); FunctionsToExport = @('Invoke-Task') } -> Option B
  4. Quick Check:

    Use arrays (@()) for RequiredModules and FunctionsToExport [OK]
Hint: Always use @() arrays for RequiredModules and FunctionsToExport [OK]
Common Mistakes:
  • Using strings instead of arrays for RequiredModules
  • Using strings instead of arrays for FunctionsToExport
  • Mixing array and string syntax
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard