Home

EnterPSSession

Enter-PSSession is a PowerShell cmdlet used to start an interactive remote session with a computer through PowerShell Remoting. When connected, commands entered in the local session are executed on the remote machine until the session is closed.

Remoting generally relies on WinRM on Windows hosts, or SSH-based remoting in newer PowerShell versions. The

Typical usage includes entering a remote session with Enter-PSSession -ComputerName Server01, or Enter-PSSession -Session $s where

Relationship to other commands: New-PSSession creates a persistent session object suitable for reuse with Invoke-Command, while

See also: Exit-PSSession, New-PSSession, Invoke-Command, Enable-PSRemoting.

target
must
be
configured
to
allow
remote
connections,
and
the
caller
must
have
appropriate
permissions.
You
can
connect
by
computer
name
or
by
an
existing
PSSession
object.
Common
parameters
include
-ComputerName,
-Session,
-Credential,
and
-Authentication.
-ConfigurationName
can
specify
a
specific
remoting
endpoint;
-UseSSL
and
-Port
may
be
used
for
non-default
transports.
$s
was
created
with
New-PSSession.
You
can
also
supply
credentials
via
-Credential
(Get-Credential).
Once
connected,
you
can
run
commands
as
if
you
were
logged
into
the
remote
host.
To
end
the
interactive
session,
use
Exit-PSSession
or
Exit.
Enter-PSSession
provides
an
interactive
shell
on
the
remote
computer.
Invoke-Command
can
run
non-interactively
against
one
or
more
remote
sessions.
In
modern
environments,
PowerShell
Remoting
may
also
operate
over
SSH
as
an
alternative
transport.