Bird
0
0

Why does Remove-PSSession not throw an error if you try to remove a session that does not exist?

hard📝 Conceptual Q10 of 15
PowerShell - Remote Management
Why does Remove-PSSession not throw an error if you try to remove a session that does not exist?
AIt always throws an error for non-existent sessions
BRemove-PSSession creates a new session if none exists
CIt silently ignores non-existent sessions to avoid script interruption
DIt prompts the user before removing
Step-by-Step Solution
Solution:
  1. Step 1: Understand Remove-PSSession behavior

    It is designed to be safe and not stop scripts by ignoring missing sessions.
  2. Step 2: Evaluate other options

    It does not throw errors, create sessions, or prompt users.
  3. Final Answer:

    It silently ignores non-existent sessions to avoid script interruption -> Option C
  4. Quick Check:

    Remove-PSSession ignores missing sessions silently [OK]
Quick Trick: Remove-PSSession ignores missing sessions without error [OK]
Common Mistakes:
  • Expecting errors on missing sessions
  • Thinking it creates sessions
  • Assuming it prompts user

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes