Enter-PSSession: Start a Remote PowerShell Session (Examples)

3 min read James Futhey Updated November 13, 2026
Microsoft Learn documentation for the Enter-PSSession cmdlet showing its PowerShell syntax

Quick answer: Run Enter-PSSession -ComputerName Server01 to open an interactive PowerShell session on a remote computer. Your prompt changes to [Server01]: PS> and every command runs there. Type exit or run Exit-PSSession to leave. The short alias is etsn.

What does Enter-PSSession do?

Enter-PSSession starts an interactive session with one remote computer. Commands you type run on that computer, as if you were sitting at it. You can have only one interactive session at a time.

By default it connects over WinRM. Starting with PowerShell 6.0 it can also connect over SSH, which works across Windows, Linux and macOS.

Microsoft says not to call it from a script or function: it's built to replace your current interactive session. For scripts, use Invoke-Command.

What do I need before connecting?

  • PowerShell remoting turned on at the remote computer. See Enable-PSRemoting.
  • Membership in the Administrators group on the remote computer.
  • For a session on the local computer, PowerShell started with Run as administrator.
  • For SSH, SSH on your computer and a PowerShell SSH endpoint configured on the remote one.

Enter-PSSession examples

Goal Command
Connect by computer name Enter-PSSession -ComputerName Server01
Connect with other credentials Enter-PSSession -ComputerName Server01 -Credential Domain01\User01
Connect over HTTPS Enter-PSSession -ComputerName Server01 -UseSSL
Connect on a custom port Enter-PSSession -ComputerName Server01 -Port 90 -Credential Domain01\User01
Enter an existing session $s = New-PSSession -ComputerName Server01; Enter-PSSession -Session $s
Connect over SSH Enter-PSSession -HostName UserA@LinuxServer01
SSH with a key and port Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath C:\sshkeys\userAKey_rsa
Connect to a virtual machine Enter-PSSession -VMName VM01 -Credential (Get-Credential)
Connect to a container Enter-PSSession -ContainerId <id> -RunAsAdministrator
Leave the session Exit-PSSession or exit

Connecting with a username and password

Pass a username and PowerShell prompts for the password:

Enter-PSSession -ComputerName Server01 -Credential Domain01\User01

Or build the credential first and reuse it. See Get-Credential in PowerShell:

$cred = Get-Credential
Enter-PSSession -ComputerName Server01 -Credential $cred

Connecting by IP address

To use an IP address with -ComputerName, you must include -Credential. The remote computer must also use HTTPS, or its IP address must be in the WinRM TrustedHosts list on your computer.

Which port does Enter-PSSession use?

Transport Default port
WinRM over HTTP 5985
WinRM over HTTPS (-UseSSL) 5986
SSH (-HostName) 22

Only use -Port if you must. The remote WinRM listener has to be set up on that port first.

-UseSSL adds HTTPS on top of WinRM's own encryption. If SSL isn't available on the port, the command fails.

Enter-PSSession vs New-PSSession vs Invoke-Command

Cmdlet What it does Use it for
Enter-PSSession Interactive prompt on one remote computer Hands-on troubleshooting
New-PSSession Creates a persistent session you can reuse Keeping state across several commands
Invoke-Command Runs a command or script block remotely Scripts and many computers at once

They work together. Create a session with New-PSSession, then enter it with Enter-PSSession -Session $s. When you exit, that session stays open for later use. A session started with -ComputerName ends when you exit.

Troubleshooting

Symptom Likely cause Fix
Can't connect at all Remoting is off on the remote computer Run Enable-PSRemoting there
Access denied Your account isn't an administrator on the remote computer Use -Credential with an admin account
Fails with an IP address No credential, or IP not trusted Add -Credential and use HTTPS or TrustedHosts
-UseSSL fails No HTTPS listener on the port Set up an HTTPS listener on 5986
Local session fails PowerShell not elevated Start PowerShell with Run as administrator
-HostName not found Windows PowerShell 5.1 Use PowerShell 6.0 or later for SSH
Session hangs on enter The session is busy running a command Wait, or press CTRL+C to cancel

Summary

  • Enter-PSSession -ComputerName Server01 opens a remote prompt; exit leaves it.
  • Add -Credential for another account and -UseSSL for HTTPS on port 5986.
  • Use -HostName for SSH in PowerShell 6.0 and later.
  • Use Invoke-Command, not Enter-PSSession, inside scripts.

Related: Enable-PSRemoting, Get-Credential.

Meeting Room 365 turns any iPad or Android tablet into a room display for Exchange and Microsoft 365 calendars. See the features or pricing: $9 a display a month.

Add a display to your office

Every room, on the door.

Live availability on every meeting room. Works with Microsoft 365, Exchange and Google Workspace.