@@ -10,23 +10,23 @@ title: about_PSSessions
1010
1111## Short description
1212
13- Describes PowerShell sessions (PSSessions) and explains how to
14- establish a persistent connection to a remote computer.
13+ Describes PowerShell sessions (PSSessions) and explains how to establish a
14+ persistent connection to a remote computer.
1515
1616## Long description
1717
1818To run PowerShell commands on a remote computer, you can use the
19- ** ComputerName** parameter of a cmdlet, or you can create a PowerShell
20- session (PSSession) and run commands in the PSSession.
19+ ** ComputerName** parameter of a cmdlet, or you can create a PowerShell session
20+ (PSSession) and run commands in the PSSession.
2121
22- When you create a PSSession, PowerShell establishes a persistent
23- connection to the remote computer. Use a PSSession to run a series of related
24- commands on a remote computer. Commands that run in the same PSSession can
25- share data, such as the values of variables, aliases, and functions.
22+ When you create a PSSession, PowerShell establishes a persistent connection to
23+ the remote computer. Use a PSSession to run a series of related commands on a
24+ remote computer. Commands that run in the same PSSession can share data, such
25+ as the values of variables, aliases, and functions.
2626
2727You can also create a PSSession on the local computer and run commands in it.
28- A local PSSession uses the PowerShell remoting infrastructure to
29- create and maintain the PSSession.
28+ A local PSSession uses the PowerShell remoting infrastructure to create and
29+ maintain the PSSession.
3030
3131Beginning in Windows PowerShell 3.0, PSSessions on Windows are independent
3232of the sessions in which they are created. Active PSSessions are maintained
@@ -36,36 +36,33 @@ on a remote Windows computer and reconnect to it at a later time from the
3636same computer or from a different Windows computer.
3737
3838This topic explains how to create, use, get, and delete PSSessions. For more
39- advanced information, see
40- [ about_PSSession_Details] ( about_PSSession_Details.md ) .
39+ advanced information, see [ about_PSSession_Details] [ 01 ] .
4140
42- Note: PSSessions use the PowerShell remoting infrastructure. To use
43- PSSessions, the local and remote computers must be configured for remoting.
44- For more information, see
45- [ about_Remote_Requirements] ( about_Remote_Requirements.md ) .
41+ Note: PSSessions use the PowerShell remoting infrastructure. To use PSSessions,
42+ the local and remote computers must be configured for remoting. For more
43+ information, see [ about_Remote_Requirements] [ 02 ] .
4644
4745In Windows Vista and later versions of Windows, to create a PSSession on a
48- local computer, you must start PowerShell with the "Run as
49- administrator" option.
46+ local computer, you must start PowerShell with the "Run as administrator"
47+ option.
5048
5149## What Is a Session?
5250
5351A session is an environment in which PowerShell runs.
5452
55- Each time you start PowerShell, a session is created for you, and you
56- can run commands in the session. You can also add items to your session, such
57- as modules and snap-ins, and you can create items, such as variables,
58- functions, and aliases. These items exist only in the session and are deleted
59- when the session ends.
60-
61- You can also create user-managed sessions, known as " PowerShell
62- sessions" or "PSSessions," on the local computer or on a remote computer. Like
63- the default session, you can run commands in a PSSession and add and create
64- items. However, unlike the session that starts automatically, you can control
65- the PSSessions that you create. You can get, create, configure, and remove
66- them, disconnect and reconnect to them, and run multiple commands in the same
67- PSSession. The PSSession remains available until you delete it or it times
68- out.
53+ Each time you start PowerShell, a session is created for you, and you can run
54+ commands in the session. You can also add items to your session, such as
55+ modules and snap-ins, and you can create items, such as variables, functions,
56+ and aliases. These items exist only in the session and are deleted when the
57+ session ends.
58+
59+ You can also create user-managed sessions, known as "PowerShell sessions" or
60+ "PSSessions," on the local computer or on a remote computer. Like the default
61+ session, you can run commands in a PSSession and add and create items.
62+ However, unlike the session that starts automatically, you can control the
63+ PSSessions that you create. You can get, create, configure, and remove them,
64+ disconnect and reconnect to them, and run multiple commands in the same
65+ PSSession. The PSSession remains available until you delete it or it times out.
6966
7067Typically, you create a PSSession to run a series of related commands on a
7168remote computer. When you create a PSSession on a remote computer, PowerShell
@@ -74,15 +71,14 @@ session.
7471
7572If you use the ** ComputerName** parameter of the ` Invoke-Command ` or
7673` Enter-PSSession ` cmdlet to run a remote command or to start an interactive
77- session, PowerShell creates a temporary session on the remote computer
78- and closes the session as soon as the command is complete or as soon as the
74+ session, PowerShell creates a temporary session on the remote computer and
75+ closes the session as soon as the command is complete or as soon as the
7976interactive session ends. You cannot control these temporary sessions, and you
80- cannot use them for more than a single command or a single interactive
81- session.
77+ cannot use them for more than a single command or a single interactive session.
8278
83- In PowerShell, the "current session" is the session that you are
84- working in. The "current session" can refer to any session, including a
85- temporary session or a PSSession.
79+ In PowerShell, the "current session" is the session that you are working in.
80+ The "current session" can refer to any session, including a temporary session
81+ or a PSSession.
8682
8783## Why Use a PSSession?
8884
@@ -96,10 +92,9 @@ You can run remote commands without creating a PSSession. Use the
9692or a series of unrelated commands on one or many computers.
9793
9894When you use the ** ComputerName** parameter of ` Invoke-Command ` or
99- ` Enter-PSSession ` , PowerShell establishes a temporary connection to
100- the remote computer and then closes the connection as soon as the command is
101- complete. Any data elements that you create are lost when the connection is
102- closed.
95+ ` Enter-PSSession ` , PowerShell establishes a temporary connection to the remote
96+ computer and then closes the connection as soon as the command is complete.
97+ Any data elements that you create are lost when the connection is closed.
10398
10499Other cmdlets that have a ** ComputerName** parameter, such as ` Get-Eventlog `
105100and ` Get-WmiObject ` , use different remoting technologies to gather data. None
@@ -108,8 +103,8 @@ create a persistent connection like a PSSession.
108103## How to Create a PSSession
109104
110105To create a PSSession, use the ` New-PSSession ` cmdlet. To create the PSSession
111- on a remote computer, use the ** ComputerName** parameter of the
112- ` New-PSSession ` cmdlet.
106+ on a remote computer, use the ** ComputerName** parameter of the ` New-PSSession `
107+ cmdlet.
113108
114109For example, the following command creates a new PSSession on the Server01
115110computer.
@@ -151,7 +146,8 @@ To get the PSSessions that were created in your current session, use the
151146` Get-PSSession ` cmdlet without the ** ComputerName** parameter. ` Get-PSSession `
152147returns the same type of object that ` New-PSSession ` returns.
153148
154- The following command gets all the PSSessions that were created in the current session.
149+ The following command gets all the PSSessions that were created in the current
150+ session.
155151
156152``` powershell
157153Get-PSSession
@@ -239,7 +235,7 @@ until it times out.
239235
240236You can also use the ** IdleTimeout** parameter of the ` New-PSSessionOption `
241237cmdlet to set an expiration time for an idle PSSession. For more information,
242- see [ New-PSSessionOption] ( xref:Microsoft.PowerShell.Core.New-PSSessionOption ) .
238+ see [ New-PSSessionOption] [ 03 ] .
243239
244240## The PSSession Cmdlets
245241
@@ -263,22 +259,37 @@ Get-Help *-PSSession
263259> Disconnected sessions are only supported on Windows. The ` Connect-PSSession ` ,
264260> ` Disconnect-PSSession ` , and ` Receive-PSSession ` cmdlets are only available
265261> on Windows. For more information about disconnected sessions, see
266- > [ about_Remote_Disconnected_Session] ( about_Remote_Disconnected_Sessions.md )
262+ > [ about_Remote_Disconnected_Session] [ 04 ] .
267263
268264## For More Information
269265
270- For more information about PSSessions, see [ about_PSSession_Details] ( about_PSSession_Details.md ) .
266+ For more information about PSSessions, see [ about_PSSession_Details] [ 01 ] .
271267
272268## See also
273269
274- - [ about_Remote] ( about_Remote.md )
275- - [ about_Remote_Disconnected_Sessions] ( about_Remote_Disconnected_Sessions.md )
276- - [ about_Remote_Requirements] ( about_Remote_Requirements.md )
277- - [ Invoke-Command] ( xref:Microsoft.PowerShell.Core.Invoke-Command )
278- - [ Connect-PSSession] ( xref:Microsoft.PowerShell.Core.Connect-PSSession )
279- - [ Disconnect-PSSession] ( xref:Microsoft.PowerShell.Core.Disconnect-PSSession )
280- - [ Enter-PSSession] ( xref:Microsoft.PowerShell.Core.Enter-PSSession )
281- - [ Exit-PSSession] ( xref:Microsoft.PowerShell.Core.Exit-PSSession )
282- - [ Get-PSSession] ( xref:Microsoft.PowerShell.Core.Get-PSSession )
283- - [ New-PSSession] ( xref:Microsoft.PowerShell.Core.New-PSSession )
284- - [ Remove-PSSession] ( xref:Microsoft.PowerShell.Core.Remove-PSSession )
270+ - [ about_Remote] [ 05 ]
271+ - [ about_Remote_Disconnected_Sessions] [ 04 ]
272+ - [ about_Remote_Requirements] [ 02 ]
273+ - [ Invoke-Command] [ 06 ]
274+ - [ Connect-PSSession] [ 07 ]
275+ - [ Disconnect-PSSession] [ 08 ]
276+ - [ Enter-PSSession] [ 09 ]
277+ - [ Exit-PSSession] [ 10 ]
278+ - [ Get-PSSession] [ 11 ]
279+ - [ New-PSSession] [ 12 ]
280+ - [ Remove-PSSession] [ 13 ]
281+
282+ <!-- link references -->
283+ [ 01 ] : about_PSSession_Details.md
284+ [ 02 ] : about_Remote_Requirements.md
285+ [ 03 ] : xref:Microsoft.PowerShell.Core.New-PSSessionOption
286+ [ 04 ] : about_Remote_Disconnected_Sessions.md
287+ [ 05 ] : about_Remote.md
288+ [ 06 ] : xref:Microsoft.PowerShell.Core.Invoke-Command
289+ [ 07 ] : xref:Microsoft.PowerShell.Core.Connect-PSSession
290+ [ 08 ] : xref:Microsoft.PowerShell.Core.Disconnect-PSSession
291+ [ 09 ] : xref:Microsoft.PowerShell.Core.Enter-PSSession
292+ [ 10 ] : xref:Microsoft.PowerShell.Core.Exit-PSSession
293+ [ 11 ] : xref:Microsoft.PowerShell.Core.Get-PSSession
294+ [ 12 ] : xref:Microsoft.PowerShell.Core.New-PSSession
295+ [ 13 ] : xref:Microsoft.PowerShell.Core.Remove-PSSession
0 commit comments