Bird
0
0

Identify the issue in this parameter block:

medium📝 Debug Q7 of 15
PowerShell - Functions
Identify the issue in this parameter block:
param(
  [string]$Name = "John",
  [int]$Age =
)
AThe parameter $Name should not have a default value
BThe parameter $Age is missing a default value
CThe data type [int] is invalid for parameters
DParameters cannot be declared inside param()
Step-by-Step Solution
Solution:
  1. Step 1: Analyze $Name parameter

    $Name is correctly declared with a default value "John".
  2. Step 2: Analyze $Age parameter

    $Age has a type but no default value or closing parenthesis, which is invalid syntax.
  3. Step 3: Identify error

    Missing default value or value assignment for $Age causes a syntax error.
  4. Final Answer:

    The parameter $Age is missing a default value -> Option B
  5. Quick Check:

    Parameters must have valid assignments or be mandatory [OK]
Quick Trick: Parameters need valid default values or be mandatory [OK]
Common Mistakes:
  • Leaving parameters without values or mandatory attribute
  • Misplacing commas or parentheses
  • Using invalid data types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes