Challenge - 5 Problems
PSSession Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this PowerShell command?
You create a new PSSession to a remote computer and then list all active sessions. What will this command output?
PowerShell
New-PSSession -ComputerName Server01 Get-PSSession | Select-Object -Property ComputerName, State
Attempts:
2 left
💡 Hint
Think about what state a newly created PSSession has before you disconnect it.
✗ Incorrect
When you create a new PSSession, it is in the 'Opened' state until you disconnect or remove it.
📝 Syntax
intermediate2:00remaining
Which command correctly closes and removes all PSSessions?
You want to close all active PSSessions and remove them from your session list. Which command does this correctly?
Attempts:
2 left
💡 Hint
Remember the cmdlet used to remove sessions is Remove-PSSession.
✗ Incorrect
Remove-PSSession removes sessions. Get-PSSession pipes all sessions to Remove-PSSession to close and remove them.
🔧 Debug
advanced2:00remaining
Why does this script fail to reconnect to a disconnected PSSession?
You run this script but get an error when trying to reconnect:
$session = New-PSSession -ComputerName Server01
Disconnect-PSSession -Session $session
Connect-PSSession -Session $session
PowerShell
$session = New-PSSession -ComputerName Server01 Disconnect-PSSession -Session $session Connect-PSSession -Session $session
Attempts:
2 left
💡 Hint
Check if Connect-PSSession is a valid cmdlet in PowerShell.
✗ Incorrect
The Connect-PSSession cmdlet does not exist in Windows PowerShell 5.1 and earlier. It is available in PowerShell 7 and later.
🚀 Application
advanced2:00remaining
How many PSSessions remain after running this script?
You run this script:
$s1 = New-PSSession -ComputerName Server01
$s2 = New-PSSession -ComputerName Server02
Remove-PSSession -Session $s1
Get-PSSession | Measure-Object | Select-Object -ExpandProperty Count
What is the output number?
PowerShell
$s1 = New-PSSession -ComputerName Server01 $s2 = New-PSSession -ComputerName Server02 Remove-PSSession -Session $s1 Get-PSSession | Measure-Object | Select-Object -ExpandProperty Count
Attempts:
2 left
💡 Hint
Think about how many sessions you created and how many you removed.
✗ Incorrect
You created two sessions and removed one. So one session remains.
🧠 Conceptual
expert2:00remaining
What is the main benefit of using PSSession over Invoke-Command for multiple commands?
You want to run several commands on a remote computer efficiently. Why choose PSSession instead of multiple Invoke-Command calls?
Attempts:
2 left
💡 Hint
Think about connection setup and reuse.
✗ Incorrect
PSSession creates a persistent connection to the remote computer, so multiple commands run faster without reconnecting each time.