The script uses finaly instead of the correct finally keyword.
Step 2: Verify other syntax elements
Catch does not require parentheses, and semicolons are optional in PowerShell; so these are not errors.
Final Answer:
Misspelled 'finally' keyword -> Option C
Quick Check:
Keyword spelling matters: 'finally' correct = B [OK]
Hint: Check spelling of 'finally' carefully [OK]
Common Mistakes:
Thinking catch needs parentheses
Expecting semicolons after commands
Missing typo in finally keyword
5. You want to ensure a log file is always closed after writing, even if an error occurs during writing. Which Try-Catch-Finally structure correctly achieves this?
The correct order is try, then catch, then finally. The finally block always runs last.
Step 2: Identify correct usage for closing log file
try { Write-Output 'Write log' } catch { Write-Output 'Error' } finally { Close-LogFile } correctly places Close-LogFile in finally to ensure it runs always, even if an error occurs.