Bird
0
0

Find the mistake in this script:

medium📝 Debug Q7 of 15
PowerShell - Variables and Data Types
Find the mistake in this script:
$name = "John"
$name = "Doe"
Write-Output name
AMissing $ before variable in Write-Output
BCannot assign new value to $name
CVariable names cannot be strings
DWrite-Output cannot print variables
Step-by-Step Solution
Solution:
  1. Step 1: Check variable usage in Write-Output

    Write-Output needs $ before variable name to print its value.
  2. Step 2: Identify the error

    Using 'name' without $ prints the literal string 'name', not variable content.
  3. Final Answer:

    Missing $ before variable in Write-Output -> Option A
  4. Quick Check:

    Variables need $ to be referenced [OK]
Quick Trick: Always use $ to access variable values [OK]
Common Mistakes:
  • Forgetting $ before variable
  • Thinking variables cannot be reassigned
  • Assuming Write-Output can't print variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes