Bird
0
0

Identify the error in this PowerShell function definition:

medium📝 Debug Q14 of 15
PowerShell - Functions
Identify the error in this PowerShell function definition:
function SayHello {
param($name)
Write-Output "Hello, $name"
}
ANo error, function is correct
Bparam block should be inside braces
CMissing parentheses after function name
DWrite-Output cannot use double quotes
Step-by-Step Solution
Solution:
  1. Step 1: Review PowerShell function syntax

    Functions use 'function Name { param(...) ... }' syntax; parentheses after name are optional.
  2. Step 2: Check param block and Write-Output usage

    Param block is correctly inside braces; double quotes allow variable expansion in Write-Output.
  3. Final Answer:

    No error, function is correct -> Option A
  4. Quick Check:

    Function syntax is valid as written [OK]
Quick Trick: Param block inside braces is correct; parentheses after name optional [OK]
Common Mistakes:
  • Expecting parentheses after function name
  • Thinking param must be outside braces
  • Believing double quotes disallowed in Write-Output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes