Bird
0
0

What will be the output of this PowerShell code?

medium📝 Predict Output Q4 of 15
PowerShell - Modules and Script Organization
What will be the output of this PowerShell code?
Import-Module MyModule
Get-Command -Module MyModule | Select-Object -ExpandProperty Name
AReturns nothing because Get-Command does not work with modules
BShows an error because MyModule is not imported
CLists all command names available in MyModule
DDisplays the content of MyModule file
Step-by-Step Solution
Solution:
  1. Step 1: Understand Import-Module effect

    Importing MyModule loads its commands into the session.
  2. Step 2: Analyze Get-Command usage

    Get-Command with -Module lists all commands from that module; Select-Object extracts their names.
  3. Final Answer:

    Lists all command names available in MyModule -> Option C
  4. Quick Check:

    Get-Command output = D [OK]
Quick Trick: Get-Command -Module lists module commands [OK]
Common Mistakes:
  • Assuming module is not imported after Import-Module
  • Thinking Get-Command shows file content
  • Believing Get-Command cannot list module commands

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes