You are currently viewing PowerShell Enter-PSSession Cmdlet

PowerShell Enter-PSSession Cmdlet

PowerShell Enter-PSSession Cmdlet

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed Get-PSSession cmdlet in PowerShell.

In this blog post, we will discuss Enter-PSSession cmdlet in PowerShell. You can use Enter-PSSession cmdlet to start an interactive session with a local or remote computer. Using Enter-PSSession cmdlet, you can create a new PSSession to a local or remote computer or connect to an existing PSSession created by New-PSSession cmdlet. You can connect to only a single interactive PSSession at a time.

Interactive PSSession behaves normally like any other PowerShell session but the command is directly executed on the remote computer and results are returned to your local computer as if you have opened a PowerShell session on the remote computer directly. You can use Exit-PSSession cmdlet or exit command to exit interactive PSSession.

Enter-PSSession Cmdlet Syntax:

Enter-PSSession Cmdlet Argument List:

  • AllowRedirection: Allows redirection of this connection to an alternate Uniform Resource Identifier (URI). By default, redirection is not allowed.
  • ApplicationName: Specifies the application name segment of the connection URI. Use this parameter to specify the application name when you are not using the ConnectionURI parameter in the command.
  • Authentication: Specifies the mechanism that is used to authenticate the user’s credentials. The acceptable values for this parameter are:
    • Default
    • Basic
    • Credssp
    • Digest
    • Kerberos
    • Negotiate
    • NegotiateWithImplicitCredential
  • CertificateThumbprint: Specifies the digital public key certificate (X509) of a user account that has permission to perform this action. Enter the certificate thumbprint of the certificate.
  • ComputerName: Specifies a computer name. This cmdlet starts an interactive session with the specified remote computer. Enter only one computer name. The default is the local computer.
  • ConfigurationName: Specifies the session configuration that is used for the interactive session.
  • ConnectionUri: Specifies a URI that defines the connection endpoint for the session. The URI must be fully qualified. The format of this string is as follows: <Transport>://<ComputerName>:<Port>/<ApplicationName> The default value is as follows: http://localhost:5985/WSMAN
  • ContainerId: Specifies the ID of a container.
  • Credential: Specifies a user account that has permission to perform this action. The default is the current user.
  • EnableNetworkAccess: Indicates that this cmdlet adds an interactive security token to loopback sessions. The interactive token lets you run commands in the loopback session that get data from other computers.
  • Id: Specifies the ID of an existing session. Enter-PSSession uses the specified session for the interactive session.
  • InstanceId: Specifies the instance ID of an existing session. Enter-PSSession uses the specified session for the interactive session.
  • Name: Specifies the friendly name of an existing session. Enter-PSSession uses the specified session for the interactive session.
  • Port: Specifies the network port on the remote computer that is used for this command. To connect to a remote computer, the remote computer must be listening on the port that the connection uses. The default ports are 5985, which is the WinRM port for HTTP, and 5986, which is the WinRM port for HTTPS.
  • RunAsAdministrator: Indicates that the PSSession runs as administrator.
  • Session: Specifies a Windows PowerShell session (PSSession) to use for the interactive session. This parameter takes a session object. You can also use the Name, InstanceID, or ID parameters to specify a PSSession.
  • SessionOption: Sets advanced options for the session. Enter a SessionOption object, such as one that you create by using the New-PSSessionOption cmdlet, or a hash table in which the keys are session option names and the values are session option values.
  • UseSSL: Indicates that this cmdlet uses the Secure Sockets Layer (SSL) protocol to establish a connection to the remote computer. By default, SSL is not used.
  • VMId: Specifies the ID of a virtual machine.
  • VMName: Specifies the name of a virtual machine.

PowerShell Enter-PSSession Cmdlet:

Hope you have enjoyed this article. In the next blog post, we will discuss Exit-PSSession CmdLet in PowerShell.

To get more details on PowerShell, kindly follow below official documentation


This Post Has One Comment

  1. Avatar


    Thank you with this script.

    When I use it on my local computer called “mycomputer”, hostname shows “mycomputer” and of course I want “System1”.

Leave a Reply