PowerShell Logo Small

Enter-PSSession



This is the built-in help made by Microsoft for the command 'Enter-PSSession', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Starts an interactive session with a remote computer.

SYNTAX


Enter-PSSession [-ComputerName] <string> [-ApplicationName <string>] [-Authentication {Default | Basic | Negotiate | NegotiateWithImplicitCredent
ial | Credssp | Digest | Kerberos}] [-CertificateThumbprint <string>] [-ConfigurationName <string>] [-Credential <PSCredential>] [-Port <int>] [-
SessionOption <PSSessionOption>] [-UseSSL] [<CommonParameters>]
Enter-PSSession [[-Id] <int>] [<CommonParameters>]
Enter-PSSession [-InstanceId <Guid>] [<CommonParameters>]
Enter-PSSession [-Name <string>] [<CommonParameters>]
Enter-PSSession [[-Session] <PSSession>] [<CommonParameters>]
Enter-PSSession [[-ConnectionURI] <Uri>] [-AllowRedirection] [-Authentication {Default | Basic | Negotiate | NegotiateWithImplicitCredential | Cr
edssp | Digest | Kerberos}] [-CertificateThumbprint <string>] [-ConfigurationName <string>] [-Credential <PSCredential>] [-SessionOption <PSSessi
onOption>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


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 though 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 New-PSSession for the interactive session.

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



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=135210
about_PSSessions
about_Remote
New-PSSession
Get-PSSession
Exit-PSSession
Remove-PSSession
Invoke-Command

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>Enter-PSSession

LocalHost\PS>



Description
-----------
This command starts an interactive session on the local computer. The command prompt changes to indicate that you are now running commands in a d
ifferent session.

The commands that you enter run in the new session, and the results are returned to the default session as text.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>enter-pssession -computer Server01

Server01\PS> get-process powershell > C:\ps-test\process.txt

Server01\PS> exit-pssession
C:\PS>

C:\PS> dir C:\ps-test\process.txt
Get-ChildItem : Cannot find path 'C:\ps-test\process.txt' because it does not exist.
At line:1 char:4
+ dir <<<< c:\ps-test\process.txt



Description
-----------
This command shows how to work in an interactive session with a remote computer.

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

The second command gets the PowerShell 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.

The fourth command confirms that the Process.txt file is on the remote computer. A Get-ChildItem ("dir") command on the local computer cannot fin
d the file.








-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> Enter-PSSession -session $s

Server01\PS>



Description
-----------
These commands use the Session parameter of Enter-PSSession to run the interactive session in an existing Windows PowerShell session (PSSession).








-------------------------- EXAMPLE 4 --------------------------

C:\PS>Enter-PSSession -computername Server01 -port 90 -credential domain01\user01

Server01\PS>



Description
-----------
This command starts an interactive session with the Server01 computer. It uses the Port parameter to specify the port and the Credential paramete
r to specify the account of a user with permission to connect to the remote computer.








-------------------------- EXAMPLE 5 --------------------------

C:\PS>Enter-PSSession -computername Server01

Server01:\PS> Exit-PSSession

C:\PS>



Description
-----------
This example shows how to start and stop an interactive session. The first command uses the Enter-PSSession cmdlet to start an interactive sessio
n with the Server01 computer.

The second command uses the Exit-PSSession cmdlet to end the session. You can also use the Exit keyword to end the interactive session. Exit-PSSe
ssion and Exit have the same effect.