0
0
PowerShellscripting~5 mins

Enter-PSSession in PowerShell

Choose your learning style9 modes available
Introduction

Enter-PSSession lets you connect to another computer and run commands there as if you were sitting in front of it. This helps you manage computers remotely without leaving your desk.

You want to fix a problem on a remote computer without physically going there.
You need to check or change settings on a server from your own computer.
You want to run a command on another computer to gather information.
You are managing many computers and want to work on one at a time remotely.
Syntax
PowerShell
Enter-PSSession -ComputerName <string> [-Credential <PSCredential>] [-Port <int>] [-UseSSL] [-SessionOption <PSSessionOption>] [-Authentication <AuthenticationMechanism>] [-ConfigurationName <string>] [-ThrottleLimit <int>] [-EnableNetworkAccess] [-ApplicationName <string>] [-AllowRedirection] [-UseUTF16] [-Session <PSSession>] [<CommonParameters>]

You usually specify the remote computer name with -ComputerName.

If needed, provide credentials with -Credential to log in remotely.

Examples
Connects to the remote computer named Server01 using your current user credentials.
PowerShell
Enter-PSSession -ComputerName Server01
Prompts you to enter a username and password to connect to Server01.
PowerShell
Enter-PSSession -ComputerName Server01 -Credential (Get-Credential)
Connects to the remote computer at IP 192.168.1.10 using a secure SSL connection.
PowerShell
Enter-PSSession -ComputerName 192.168.1.10 -UseSSL
Sample Program

This script connects to your own computer remotely, lists running processes, then exits the remote session.

PowerShell
Enter-PSSession -ComputerName localhost
Get-Process
Exit-PSSession
OutputSuccess
Important Notes

Use Exit-PSSession to leave the remote session and return to your local prompt.

Remote computers must allow PowerShell remoting and have it enabled to connect.

For security, use credentials and SSL when connecting over untrusted networks.

Summary

Enter-PSSession lets you open a remote PowerShell session on another computer.

You can run commands on that remote computer as if you were there.

Remember to exit the session when done to return to your local computer.