0
0
PowerShellscripting~10 mins

PSSession management in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new PowerShell session to a remote computer named 'Server01'.

PowerShell
$session = New-PSSession -ComputerName [1]
Drag options to blanks, or click blank then click option'
ARemotePC
Blocalhost
CServer01
DMyServer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'localhost' instead of the remote computer name.
Using a generic name not matching the remote computer.
2fill in blank
medium

Complete the code to enter an existing PSSession stored in the variable $session.

PowerShell
Enter-PSSession -[1] $session
Drag options to blanks, or click blank then click option'
AComputerName
BSessionId
CName
DSession
Attempts:
3 left
💡 Hint
Common Mistakes
Using -SessionId instead of -Session.
Using -ComputerName which expects a string, not a session object.
3fill in blank
hard

Fix the error in the code to remove all PSSessions.

PowerShell
Get-PSSession | [1]-PSSession
Drag options to blanks, or click blank then click option'
ARemove
BDelete
CClear
DClose
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Delete-PSSession' which does not exist.
Using 'Clear-PSSession' or 'Close-PSSession' which are invalid.
4fill in blank
hard

Fill both blanks to create a new PSSession to 'Server02' and store it in $sess.

PowerShell
$sess = [1] -ComputerName [2]
Drag options to blanks, or click blank then click option'
ANew-PSSession
BEnter-PSSession
CServer02
DServer01
Attempts:
3 left
💡 Hint
Common Mistakes
Using Enter-PSSession instead of New-PSSession.
Using the wrong computer name.
5fill in blank
hard

Fill all three blanks to filter PSSessions with state 'Opened' and remove them.

PowerShell
Get-PSSession | Where-Object { $_.State -eq '[1]' } | [2]-PSSession -[3]
Drag options to blanks, or click blank then click option'
AClosed
BRemove
CForce
DOpened
Attempts:
3 left
💡 Hint
Common Mistakes
Filtering for 'Closed' instead of 'Opened'.
Using 'Delete-PSSession' which is invalid.
Omitting the '-Force' parameter causing removal failure.