Bird
0
0

Identify the error in this PowerShell script:

medium📝 Debug Q14 of 15
PowerShell - Variables and Data Types
Identify the error in this PowerShell script:
$age = 30
Write-Output age
AVariable $age cannot store numbers
BMissing $ before variable name in Write-Output
CWrite-Output cannot print variables
DAssignment operator = is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check variable usage in Write-Output

    Variables must have $ prefix when used, so "age" is incorrect.
  2. Step 2: Verify other parts

    $age = 30 is valid; Write-Output can print variables; = is correct.
  3. Final Answer:

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

    Variables need $ prefix = A [OK]
Quick Trick: Always use $ before variable names when referencing [OK]
Common Mistakes:
  • Forgetting $ before variable in commands
  • Thinking variables can't hold numbers
  • 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