PowerShell Logo Small

Exit-PSSession



This is the built-in help made by Microsoft for the command 'Exit-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

Ends an interactive session with a remote computer.

SYNTAX


Exit-PSSession [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Exit-PSSession cmdlet ends interactive sessions that you started by using Enter-PSSession.

You can also use the Exit keyword to end an interactive session. The effect is the same as using Exit-PSSession.



<

RELATED LINKS

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

REMARKS

<

Examples


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

C:\PS>Enter-PSSession -computername Server01

Server01\PS> Exit-PSSession

C:\PS>



Description
-----------
These commands start and then stop an interactive session with the Server01 remote computer.








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

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

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

Server01\PS> Exit-PSSession

C:\PS> $s

Id Name ComputerName State ConfigurationName
-- ---- ------------ ----- -----------------
1 Session1 Server01 Opened Microsoft.PowerShell



Description
-----------
These commands start and stop an interactive session with the Server01 computer that uses a Windows PowerShell session (PSSession).

Because the interactive session was started by using a Windows PowerShell session (PSSession), the PSSession is still available when the interact
ive session ends. If you use the ComputerName parameter, Enter-PSSession creates a temporary session that it closes when the interactive session
ends.

The first command uses the New-PSSession cmdlet to create a PSSession on the Server01 computer. The command saves the PSSession in the $s variabl
e.

The second command uses the Enter-PSSession cmdlet to start an interactive session using the PSSession in $s.

The third command uses the Exit-PSSession cmdlet to stop the interactive session.

The final command displays the PSSession in the $s variable. The State property shows the PSSession is still open and available for use.








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

C:\PS>Enter-PSSession -computername Server01

Server01\PS> exit

C:\PS>



Description
-----------
This command uses the Exit keyword to stop an interactive session started by using the Enter-PSSession cmdlet. The Exit keyword has the same effe
ct as using Exit-PSSession.