Challenge - 5 Problems
PowerShell Module Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of importing a module with a function?
You have a PowerShell module file named
After running
MyTools.psm1 containing this function:function Get-Greeting { "Hello, World!" }After running
Import-Module .\MyTools.psm1 and then Get-Greeting, what is the output?PowerShell
function Get-Greeting { "Hello, World!" } Import-Module .\MyTools.psm1 Get-Greeting
Attempts:
2 left
💡 Hint
Think about what the function returns when called after importing the module.
✗ Incorrect
When you import a module with a function, calling that function outputs its return value. Here,
Get-Greeting returns the string "Hello, World!".📝 Syntax
intermediate2:00remaining
Which option correctly defines a PowerShell module manifest?
You want to create a module manifest file
MyTools.psd1 for your module. Which snippet correctly starts the manifest with the required syntax?Attempts:
2 left
💡 Hint
A module manifest is a PowerShell hashtable saved in a .psd1 file.
✗ Incorrect
A module manifest is a PowerShell hashtable enclosed in @{} braces. Option B correctly uses this syntax.
🔧 Debug
advanced2:00remaining
Why does this module function fail to export?
You have a module file
After importing the module, running
MyTools.psm1 with this content:function Get-Secret { "Top Secret" }
Export-ModuleMember -Function Get-SecretAfter importing the module, running
Get-Secret gives an error: Get-Secret : The term 'Get-Secret' is not recognized. Why?PowerShell
function Get-Secret { "Top Secret" } Export-ModuleMember -Function Get-Secret
Attempts:
2 left
💡 Hint
Check how the function name is passed to Export-ModuleMember.
✗ Incorrect
Export-ModuleMember requires the function names as strings. Without quotes, it does not export the function.
🚀 Application
advanced2:00remaining
How to automatically import a module when a function is called?
You want to create a module that loads only when its function is called, to save memory. Which method achieves this in PowerShell?
Attempts:
2 left
💡 Hint
PowerShell can auto-load modules placed in specific folders.
✗ Incorrect
PowerShell auto-loads modules when a command from the module is called if the module is in a standard module path.
🧠 Conceptual
expert2:00remaining
What is the main purpose of a PowerShell module manifest?
Choose the best description of what a module manifest (.psd1) file does in PowerShell module creation.
Attempts:
2 left
💡 Hint
Think about what information helps PowerShell manage the module.
✗ Incorrect
A module manifest is a metadata file that describes the module, its version, dependencies, and which commands to export.