Bird
0
0

What will happen when running this command?

medium📝 Command Output Q5 of 15
PowerShell - Error Handling
What will happen when running this command?
Remove-Item 'C:\temp\file.txt' -ErrorAction Stop
if the file does not exist?
AThe command silently ignores the error
BThe command throws an error and stops execution
CThe command logs the error but continues
DThe command retries deleting the file
Step-by-Step Solution
Solution:
  1. Step 1: Analyze -ErrorAction Stop effect

    This option stops the script immediately on error.
  2. Step 2: Consider file absence

    Since the file doesn't exist, an error occurs and script stops.
  3. Final Answer:

    The command throws an error and stops execution -> Option B
  4. Quick Check:

    Stop halts script on error [OK]
Quick Trick: Stop halts script immediately on error [OK]
Common Mistakes:
  • Assuming error is ignored
  • Thinking script retries automatically
  • Confusing Stop with SilentlyContinue

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes