Enter-PSSession | Taking on PowerShell one cmdlet at a time | Weekly Blog

Share this post:

This is a part of an on-going blog series written by Adam Gordon. Each week, Adam will walk you through a PowerShell command, showing you when and how to use each one. This week, Adam covers Enter-PSSession.

When to use Enter-PSSession?

The Enter-PSSession cmdlet starts an interactive session with a single remote computer. During the session, the commands that you type run on the remote computer, just as if you were typing directly on the remote computer. You can have only one interactive session at a time.

Typically, you use the -ComputerName parameter to specify the name of the remote computer. However, you can also use a session that you create by using the New-PSSession cmdlet for the interactive session. However, you cannot use the Disconnect-PSSession, Connect-PSSession, or Receive-PSSession cmdlets to disconnect from or re-connect to an interactive session.

Starting with PowerShell 6.0 you can use Secure Shell (SSH) to establish a connection to a remote computer if SSH is available on the local computer and the remote computer is configured with a PowerShell SSH endpoint.

The benefit of an SSH based PowerShell remote session is that it works across multiple platforms (Windows, Linux, macOS). For SSH based remoting you use the –HostName parameter set to specify the remote computer and relevant connection information.

To end the interactive session and disconnect from the remote computer, use the Exit-PSSession cmdlet, or type exit.

What version of PowerShell am I using for this blog?

Get the PowerShell Version from your machine:


This command shows you the PowerShell version information on your machine.

How to use Enter-PSSession?

Work with an interactive session:

Enter-PSSession -ComputerName SCCMDC

The first command uses the Enter-PSSession cmdlet to start an interactive session with SCCMDC, a remote computer. When the session starts, the command prompt changes to include the computer name.

Get-Process “tiworker” > C:\ps-test\Process.txt

The second command gets the TIWorker process and redirects the output to the Process.txt file. The command is submitted to the remote computer, and the file is saved on the remote computer.


The third command uses the Exit keyword to end the interactive session and close the connection.

Learn last week’s command: Get-DnsServer.

Need PowerShell training? Check out ITProTV’s PowerShell online IT training courses.

Leave a Reply

Your email address will not be published. Required fields are marked *