SSH-based remoting allows you to run PowerShell commands on a remote computer securely using the SSH protocol. It works across different platforms like Windows, Linux, and macOS.
Click to reveal answer
beginner
How do you start an SSH-based PowerShell session to a remote computer?
Use the command: Enter-PSSession -HostName <remote-computer> -UserName <user>. This opens an interactive session over SSH.
Click to reveal answer
intermediate
What must be installed and configured on the remote machine to use SSH-based remoting?
The remote machine must have an SSH server running and PowerShell 7+ installed. The SSH server handles the connection securely.
Click to reveal answer
intermediate
Which PowerShell cmdlet is used to run a command on a remote computer over SSH without entering an interactive session?
Use Invoke-Command -HostName <remote-computer> -UserName <user> -ScriptBlock { <commands> } to run commands remotely over SSH.
Click to reveal answer
intermediate
Why is SSH-based remoting preferred over older PowerShell remoting methods on non-Windows systems?
SSH-based remoting works cross-platform and uses a secure, widely supported protocol. It does not require Windows-only services like WinRM, making it simpler and more compatible.
Click to reveal answer
Which cmdlet starts an interactive SSH-based PowerShell session?
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
Step 1: Recall Enter-PSSession syntax for SSH remoting
PowerShell 7+ uses Enter-PSSession -HostName <name> to start SSH sessions.
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.
Final Answer:
Enter-PSSession -HostName Server01 -> Option A
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?
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
Step 1: Understand the error message
The error says 'Enter-PSSession' is not recognized, meaning the command is missing locally.
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.
Final Answer:
PowerShell version is older than 7 on the local machine -> Option D
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?
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
Step 1: Understand running commands on multiple SSH hosts
Invoke-Command -HostName accepts an array of multiple host names directly in PowerShell 7+.
Step 2: Analyze options
Invoke-Command -HostName Server01,Server02 -ScriptBlock { Get-Process } runs Get-Process on both remote servers and collects the results.
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.
Final Answer:
Invoke-Command -HostName Server01,Server02 -ScriptBlock { Get-Process } -> Option C