Bird
Raised Fist0
PowerShellscripting~20 mins

SSH-based remoting (PowerShell 7+) - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
SSH Remoting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this PowerShell SSH remoting command?
You run this command in PowerShell 7+ to start an interactive session on a remote machine named 'Server01' using SSH remoting:

Enter-PSSession -HostName Server01 -UserName AdminUser

What will be the immediate output if the connection is successful?
PowerShell
Enter-PSSession -HostName Server01 -UserName AdminUser
AA prompt changes to indicate the remote session, e.g., [Server01]: PS>
BThe command outputs a list of running processes on Server01
CAn error message: 'The term Enter-PSSession is not recognized'
DThe local PowerShell session closes immediately
Attempts:
2 left
💡 Hint
Think about what Enter-PSSession does when connecting successfully.
💻 Command Output
intermediate
2:00remaining
What error occurs when SSH remoting fails due to wrong credentials?
You try to connect to a remote machine using:

Enter-PSSession -HostName Server02 -UserName WrongUser

The password is incorrect. What error message will PowerShell most likely show?
PowerShell
Enter-PSSession -HostName Server02 -UserName WrongUser
ASSH authentication failed: Permission denied (publickey,password).
BThe remote session starts successfully without error.
CError: The term 'Enter-PSSession' is not recognized.
DTimeout expired while waiting for remote command to complete.
Attempts:
2 left
💡 Hint
Think about what happens when SSH credentials are wrong.
📝 Syntax
advanced
2:00remaining
Which command correctly runs a script block on a remote machine using SSH remoting?
You want to run the script block { Get-Process | Select-Object -First 3 } on a remote machine 'Server03' using SSH remoting. Which command is syntactically correct?
AInvoke-SSHCommand -HostName Server03 -ScriptBlock { Get-Process | Select-Object -First 3 }
BInvoke-Command -ComputerName Server03 -ScriptBlock { Get-Process | Select-Object -First 3 }
CInvoke-Command -HostName Server03 -Command { Get-Process | Select-Object -First 3 }
DInvoke-Command -HostName Server03 -ScriptBlock { Get-Process | Select-Object -First 3 }
Attempts:
2 left
💡 Hint
Use the correct parameter for SSH remoting in PowerShell 7+.
🔧 Debug
advanced
2:00remaining
Why does this SSH remoting command fail with 'The term 'Enter-PSSession' is not recognized'?
You run this command in PowerShell 5.1 on Windows:

Enter-PSSession -HostName Server04 -UserName AdminUser

and get the error:

The term 'Enter-PSSession' is not recognized as the name of a cmdlet...

What is the most likely cause?
PowerShell
Enter-PSSession -HostName Server04 -UserName AdminUser
AThe user 'AdminUser' does not have permission on the remote server.
BThe remote server 'Server04' is offline.
CPowerShell 5.1 does not support SSH-based remoting with -HostName parameter.
DThe SSH service is not installed on the local machine.
Attempts:
2 left
💡 Hint
Check PowerShell version compatibility for SSH remoting.
🚀 Application
expert
3:00remaining
How to run a remote command on multiple machines using SSH remoting in PowerShell 7+?
You have a list of remote servers stored in $servers = @('ServerA', 'ServerB', 'ServerC'). You want to run Get-Service on all of them using SSH remoting and collect the results locally. Which script correctly does this?
AInvoke-Command -HostName $servers -ScriptBlock { Get-Service }
B$servers | ForEach-Object { Invoke-Command -HostName $_ -ScriptBlock { Get-Service } }
C$servers | ForEach-Object { Enter-PSSession -HostName $_ -ScriptBlock { Get-Service } }
DInvoke-SSHCommand -ComputerName $servers -Command 'Get-Service'
Attempts:
2 left
💡 Hint
Think about how to run commands on multiple hosts sequentially and collect output.

Practice

(1/5)
1. What is the main purpose of using SSH-based remoting in PowerShell 7+?
easy
A. To create graphical user interfaces in PowerShell scripts
B. To securely run commands on remote computers using PowerShell
C. To compile PowerShell scripts into executable files
D. To manage local files faster on your own computer

Solution

  1. Step 1: Understand SSH-based remoting concept

    SSH-based remoting allows secure communication to run commands on other computers remotely.
  2. Step 2: Identify the main use case in PowerShell 7+

    PowerShell 7+ uses SSH remoting to securely run commands or scripts on remote machines.
  3. Final Answer:

    To securely run commands on remote computers using PowerShell -> Option B
  4. Quick Check:

    SSH remoting = Secure remote command execution [OK]
Hint: SSH remoting = secure remote command running [OK]
Common Mistakes:
  • Confusing remoting with local script execution
  • Thinking SSH remoting creates GUIs
  • Assuming it compiles scripts
2. Which of the following is the correct syntax to start an interactive SSH-based PowerShell session to a remote computer named Server01?
easy
A. Enter-PSSession -HostName Server01
B. Invoke-Command -Session Server01 -SSH
C. Enter-PSSession -ComputerName Server01 -UseSSH
D. New-PSSession -ComputerName Server01

Solution

  1. Step 1: Recall Enter-PSSession syntax for SSH remoting

    PowerShell 7+ uses Enter-PSSession -HostName <name> to start SSH sessions.
  2. Step 2: Compare options

    Enter-PSSession -HostName Server01 uses -HostName Server01, which is correct for SSH remoting. Enter-PSSession -ComputerName Server01 -UseSSH uses -ComputerName with -UseSSH which is invalid syntax. Invoke-Command -Session Server01 -SSH mixes parameters incorrectly. New-PSSession -ComputerName Server01 creates a session but does not specify SSH or hostname properly.
  3. Final Answer:

    Enter-PSSession -HostName Server01 -> Option A
  4. Quick Check:

    SSH session uses -HostName parameter [OK]
Hint: Use Enter-PSSession with -HostName for SSH [OK]
Common Mistakes:
  • Using -ComputerName instead of -HostName for SSH
  • Mixing Invoke-Command with session parameters
  • Omitting SSH-specific parameters
3. What will be the output of this PowerShell command run locally if the remote computer Server01 is reachable and has PowerShell 7+ installed?
Invoke-Command -HostName Server01 -ScriptBlock { Get-Date }
medium
A. The current date and time from Server01
B. An error saying 'HostName parameter not recognized'
C. The current date and time from the local computer
D. No output, the command runs silently

Solution

  1. Step 1: Understand Invoke-Command with -HostName

    This runs the script block on the remote computer specified by -HostName.
  2. Step 2: Analyze the script block

    The script block calls Get-Date, which returns the current date/time on the remote machine.
  3. Final Answer:

    The current date and time from Server01 -> Option A
  4. Quick Check:

    Invoke-Command with -HostName runs remotely [OK]
Hint: Invoke-Command -HostName runs script remotely [OK]
Common Mistakes:
  • Expecting local date/time output
  • Confusing parameter names
  • Assuming no output is shown
4. You run this command but get an error:
Enter-PSSession -HostName Server01

The error says: "The term 'Enter-PSSession' is not recognized." What is the most likely cause?
medium
A. SSH service is not running on Server01
B. The remote computer Server01 is offline
C. You forgot to specify the username
D. PowerShell version is older than 7 on the local machine

Solution

  1. Step 1: Understand the error message

    The error says 'Enter-PSSession' is not recognized, meaning the command is missing locally.
  2. Step 2: Identify cause related to PowerShell version

    Enter-PSSession with -HostName for SSH remoting is available only in PowerShell 7+. Older versions do not support it.
  3. Final Answer:

    PowerShell version is older than 7 on the local machine -> Option D
  4. Quick Check:

    Command not recognized = old PowerShell version [OK]
Hint: Check PowerShell version if command not recognized [OK]
Common Mistakes:
  • Assuming remote offline causes local command error
  • Blaming SSH service without checking local version
  • Thinking username is mandatory for command recognition
5. You want to run a script on multiple remote computers Server01 and Server02 using SSH remoting in PowerShell 7+. Which command correctly runs Get-Process on both and collects results?
hard
A. Invoke-Command -Session (New-PSSession -ComputerName Server01), (New-PSSession -ComputerName Server02) -ScriptBlock { Get-Process }
B. Invoke-Command -ComputerName Server01,Server02 -UseSSH -ScriptBlock { Get-Process }
C. Invoke-Command -HostName Server01,Server02 -ScriptBlock { Get-Process }
D. Enter-PSSession -HostName Server01; Enter-PSSession -HostName Server02; Get-Process

Solution

  1. Step 1: Understand running commands on multiple SSH hosts

    Invoke-Command -HostName accepts an array of multiple host names directly in PowerShell 7+.
  2. Step 2: Analyze options

    Invoke-Command -HostName Server01,Server02 -ScriptBlock { Get-Process } runs Get-Process on both remote servers and collects the results.
  3. Step 3: Why other options are incorrect

    A uses New-PSSession -ComputerName, which targets WinRM not SSH. B uses -ComputerName with invalid -UseSSH. C enters sessions sequentially but Get-Process runs locally after.
  4. Final Answer:

    Invoke-Command -HostName Server01,Server02 -ScriptBlock { Get-Process } -> Option C
  5. Quick Check:

    Multiple SSH hosts: -HostName Server01,Server02 [OK]
Hint: Invoke-Command -HostName Server01,Server02 for multiple SSH hosts [OK]
Common Mistakes:
  • Using -ComputerName (WinRM) instead of -HostName for SSH
  • Using invalid -UseSSH parameter
  • Running commands locally after sequential Enter-PSSession
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard