Bird
0
0

Identify the error in this PowerShell formatting command:

medium📝 Debug Q14 of 15
PowerShell - String Operations
Identify the error in this PowerShell formatting command:
"User: {0}, Score: {1}" -f $user
AMissing second argument for {1} placeholder
BIncorrect placeholder syntax
CVariables should be inside the string, not after -f
DThe -f operator cannot format strings
Step-by-Step Solution
Solution:
  1. Step 1: Count placeholders and arguments

    The string has two placeholders: {0} and {1}, but only one argument ($user) is provided after -f.
  2. Step 2: Understand the consequence

    Because {1} has no matching argument, this causes an error or unexpected output.
  3. Final Answer:

    Missing second argument for {1} placeholder -> Option A
  4. Quick Check:

    Placeholders must match arguments count = C [OK]
Quick Trick: Count placeholders and arguments; they must match [OK]
Common Mistakes:
  • Providing fewer arguments than placeholders
  • Misunderstanding placeholder numbering
  • Thinking variables go inside string without -f

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes