Enter-PSSession

The Enter-PSSession command may be used to use a session as a remote console. By default, Enter-PSSession accepts a computer name as the first argument:

Enter-PSSession $env:COMPUTERNAME 

In a similar way, an existing session might be used:

$session = New-PSSession -ComputerName $env:COMPUTERNAME 
Enter-PSSession -Session $session 

Enter-PSSession uses WS-Management as a means of exchanging information between the client and the server. Once a command is typed and the return key is pressed, the entire command is sent to the remote host. The result of the command is sent back using the same mechanism. This exchange can inject a small amount of latency into the shell.

Get Mastering Windows PowerShell Scripting - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.