Bird
0
0

What is wrong with this function call?

medium📝 Debug Q7 of 15
PowerShell - Functions
What is wrong with this function call?
function ShowMessage { param($msg) Write-Output $msg } ShowMessage
AFunction name is invalid
BFunction cannot have parameters
CFunction is missing parameter when called
DWrite-Output cannot output variables
Step-by-Step Solution
Solution:
  1. Step 1: Understand function parameters

    The function expects one parameter named $msg.
  2. Step 2: Check function call

    The call 'ShowMessage' provides no argument, causing an error or empty output.
  3. Final Answer:

    Function is missing parameter when called -> Option C
  4. Quick Check:

    Functions need parameters passed if defined = D [OK]
Quick Trick: Always pass required parameters when calling functions [OK]
Common Mistakes:
  • Calling functions without required parameters
  • Thinking functions cannot have parameters
  • Assuming Write-Output cannot output variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes