Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a PSSession in PowerShell?
A PSSession is a persistent connection to a remote computer that allows you to run commands and scripts on that computer as if you were working locally.
Click to reveal answer
beginner
How do you create a new PSSession to a remote computer named 'Server01'?
Use the command: New-PSSession -ComputerName Server01 to create a new session to 'Server01'.
Click to reveal answer
beginner
How can you list all active PSSessions in your current PowerShell session?
Use Get-PSSession to see all active PSSessions you have open.
Click to reveal answer
beginner
What command closes a specific PSSession stored in a variable $session?
Use Remove-PSSession -Session $session to close and remove that session.
Click to reveal answer
intermediate
Why is it useful to use PSSessions instead of running commands directly with Invoke-Command?
PSSessions keep the connection open, so you can run multiple commands efficiently without reconnecting each time. This saves time and resources.
Click to reveal answer
Which command creates a new persistent remote session in PowerShell?
ARemove-PSSession
BNew-PSSession
CGet-PSSession
DInvoke-Command
✗ Incorrect
New-PSSession creates a new persistent remote session.
How do you see all your active remote sessions?
AGet-RemoteSession
BShow-PSSession
CGet-PSSession
DList-PSSession
✗ Incorrect
Get-PSSession lists all active PSSessions.
What does Remove-PSSession do?
ACloses and removes a session
BLists sessions
CCreates a new session
DRuns a command remotely
✗ Incorrect
Remove-PSSession closes and removes a session.
Why use PSSession over Invoke-Command for multiple commands?
APSSession keeps connection open for efficiency
BPSSession is slower
CInvoke-Command keeps connection open
DNo difference
✗ Incorrect
PSSession keeps the connection open, making multiple commands faster.
Which command runs a command inside an existing PSSession stored in $session?
But it throws an error: "Remove-PSSession : Cannot bind argument to parameter 'Session' because it is null." What is the problem?
medium
A. Invoke-Command syntax is incorrect
B. New-PSSession failed to create a session
C. Get-Date cannot run inside a PSSession
D. Remove-PSSession is missing the -Session parameter with the session variable
Solution
Step 1: Identify the error cause
The error says Remove-PSSession has a null argument for -Session, meaning it was called without specifying which session to remove.
Step 2: Check the Remove-PSSession command usage
The script calls Remove-PSSession -Session without the $session value, so PowerShell doesn't know which session to close.
Final Answer:
Remove-PSSession is missing the -Session parameter with the session variable -> Option D
Quick Check:
Remove-PSSession needs -Session argument [OK]
Hint: Always specify -Session when removing sessions [OK]
Common Mistakes:
Forgetting to pass the session variable to Remove-PSSession
Assuming Remove-PSSession closes all sessions by default
Blaming Invoke-Command or New-PSSession incorrectly
5. You want to run a command on multiple remote computers and keep the sessions open for later use. Which approach correctly creates sessions for 'Server01' and 'Server02' and stores them for reuse?
Step 1: Recall how to create persistent sessions for multiple computers
New-PSSession can take multiple ComputerName values or create separately and collect into an array with +=. Invoke-Command must use -Session $sessions (array) to run on persistent sessions.
Step 2: Evaluate each option
A creates sessions but uses -ComputerName on Invoke-Command, creating temporary connections instead of using persistent ones. B builds the array explicitly and uses -Session. C uses temporary only. D removes sessions.