Challenge - 5 Problems
PowerShell Module Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Purpose of PowerShell Modules
Why do PowerShell modules help in scripting and automation?
Attempts:
2 left
💡 Hint
Think about how you can organize your scripts to use them again without rewriting.
✗ Incorrect
PowerShell modules package related functions and scripts so you can load and reuse them easily in different scripts or sessions.
💻 Command Output
intermediate2:00remaining
Output of Import-Module Command
What is the output when you run this command in PowerShell if the module exists and loads successfully?
Import-Module -Name Microsoft.PowerShell.Utility
PowerShell
Import-Module -Name Microsoft.PowerShell.Utility
Attempts:
2 left
💡 Hint
Think about what happens when a module loads without problems.
✗ Incorrect
Import-Module runs silently if the module loads without errors, so no output appears.
📝 Syntax
advanced2:00remaining
Correct Syntax to Export Functions in a Module
Which option shows the correct way to export functions from a PowerShell module so they can be used outside the module?
PowerShell
function Get-Greeting { "Hello" } function Get-Farewell { "Goodbye" } # Export functions here
Attempts:
2 left
💡 Hint
Look for the official cmdlet that exports functions from modules.
✗ Incorrect
Export-ModuleMember with -Function parameter is the correct syntax to export functions.
🔧 Debug
advanced2:00remaining
Why Does This Module Not Export Functions?
You wrote this module script but the functions are not available after importing the module:
function Say-Hello { "Hi" }
function Say-Bye { "Bye" }
# Missing export command
Why are the functions not accessible outside the module?
Attempts:
2 left
💡 Hint
Think about how PowerShell modules share functions with the outside.
✗ Incorrect
Functions inside modules must be explicitly exported using Export-ModuleMember to be accessible outside.
🚀 Application
expert2:00remaining
Using Modules to Reuse Code in Multiple Scripts
You have a module named Utils.psm1 with a function Get-DateFormatted. How do you use this function in two different scripts without copying the function code into each script?
Attempts:
2 left
💡 Hint
Think about how to share code without duplication.
✗ Incorrect
Importing the module in each script loads the functions so they can be used without copying code.