Bird
0
0

What will this PowerShell script output?

medium📝 Command Output Q5 of 15
PowerShell - Error Handling
What will this PowerShell script output?
try {
  Write-Output 'Try block'
} finally {
  Write-Output 'Finally block'
}
ATry block
BFinally block Try block
CFinally block
DTry block Finally block
Step-by-Step Solution
Solution:
  1. Step 1: Execute try block

    The try block prints "Try block" with no errors.
  2. Step 2: Execute finally block

    The finally block runs after try and prints "Finally block".
  3. Final Answer:

    Try block Finally block -> Option D
  4. Quick Check:

    try runs first, then finally always runs [OK]
Quick Trick: finally runs after try even without errors [OK]
Common Mistakes:
  • Swapping order of outputs
  • Thinking finally runs only on error
  • Missing finally output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes