Bird
0
0

You run this code:

medium📝 Debug Q6 of 15
PowerShell - Remote Management
You run this code:
$session = New-PSSession -ComputerName Server03
Remove-PSSession $session.Id

What is the problem?
ANew-PSSession syntax is incorrect
BRemove-PSSession expects a session object, not an Id
CYou must use Enter-PSSession before Remove-PSSession
DRemove-PSSession requires -Id parameter
Step-by-Step Solution
Solution:
  1. Step 1: Check Remove-PSSession parameter requirements

    Remove-PSSession accepts session objects or pipeline input, not raw Id integers.
  2. Step 2: Identify correct usage

    Passing $session.Id (an integer) causes error; must pass $session object or use Get-PSSession to get session object first.
  3. Final Answer:

    Remove-PSSession expects a session object, not an Id -> Option B
  4. Quick Check:

    Remove-PSSession needs session object, not Id number [OK]
Quick Trick: Pass session object, not Id, to Remove-PSSession [OK]
Common Mistakes:
  • Passing session Id directly
  • Confusing Remove-PSSession with Enter-PSSession
  • Using invalid parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes