1- ---
1+ ---
22ms.date : 12/01/2017
33schema : 2.0.0
44locale : en-us
55keywords : powershell,cmdlet
66title : about_Remote_Disconnected_Sessions
77---
8-
98# About Remote Disconnected Sessions
109
1110## Short Description
@@ -44,12 +43,12 @@ location.
4443
4544The following cmdlets support the Disconnected Sessions feature:
4645
47- * ` Connect-PSSession ` : Connects to a disconnected PSSession
48- * ` Disconnect-PSSession ` : Disconnects a PSSession
49- * ` Get-PSSession ` : Gets PSSessions on the local computer or on remote computers
50- * ` Receive-PSSession ` : Gets the results of commands that ran in disconnected
46+ - ` Connect-PSSession ` : Connects to a disconnected PSSession
47+ - ` Disconnect-PSSession ` : Disconnects a PSSession
48+ - ` Get-PSSession ` : Gets PSSessions on the local computer or on remote computers
49+ - ` Receive-PSSession ` : Gets the results of commands that ran in disconnected
5150 sessions
52- * ` Invoke-Command ` : ** InDisconnectedSession** parameter creates a PSSession and
51+ - ` Invoke-Command ` : ** InDisconnectedSession** parameter creates a PSSession and
5352 disconnects immediately
5453
5554## How the Disconnected Sessions Feature Works
@@ -113,7 +112,7 @@ The first command creates a session to the Server01 computer. The session
113112resides on the Server01 computer.
114113
115114``` powershell
116- PS C:\ > New-PSSession -ComputerName Server01
115+ PS> New-PSSession -ComputerName Server01
117116
118117Id Name ComputerName State ConfigurationName Availability
119118-- ---- ------------ ----- ----------------- ------------
@@ -124,7 +123,7 @@ To get the session, use the **ComputerName** parameter of `Get-PSSession`
124123with a value of Server01.
125124
126125``` powershell
127- PS C:\ > Get-PSSession -ComputerName Server01
126+ PS> Get-PSSession -ComputerName Server01
128127
129128Id Name ComputerName State ConfigurationName Availability
130129-- ---- ------------ ----- ----------------- ------------
@@ -137,16 +136,16 @@ maintained on the local computer. It does not get PSSessions on the Server01
137136computer, even if they were started on the local computer.
138137
139138``` powershell
140- PS C:\ > Get-PSSession -ComputerName localhost
141- PS C:\ >
139+ PS> Get-PSSession -ComputerName localhost
140+ PS>
142141```
143142
144143To get sessions that were created in the current session, use the
145144` Get-PSSession ` cmdlet without parameters. This command gets the PSSession
146145that was created in the current session and connects to the Server01 computer.
147146
148147``` powershell
149- PS C:\ > Get-PSSession
148+ PS> Get-PSSession
150149
151150Id Name ComputerName State ConfigurationName Availability
152151-- ---- ------------ ----- ----------------- ------------
@@ -164,7 +163,7 @@ Notice that the value of the State property is Disconnected and the
164163Availability is None.
165164
166165``` powershell
167- PS C:\ > Get-PSSession -ComputerName Server01 | Disconnect-PSSession
166+ PS> Get-PSSession -ComputerName Server01 | Disconnect-PSSession
168167
169168Id Name ComputerName State ConfigurationName Availability
170169-- ---- ------------ ----- ----------------- ------------
@@ -179,7 +178,7 @@ The following command runs a `Get-WinEvent` command in a disconnected session
179178on the Server02 remote computer.
180179
181180``` powershell
182- PS C:\ > Invoke-Command -ComputerName Server02 -InDisconnectedSession `
181+ PS> Invoke-Command -ComputerName Server02 -InDisconnectedSession `
183182-ScriptBlock { Get-WinEvent -LogName "Windows PowerShell" }
184183
185184Id Name ComputerName State ConfigurationName Availability
@@ -207,7 +206,7 @@ The following command gets the sessions on the Server02 computer. The output
207206includes two disconnected sessions, both of which are available.
208207
209208``` powershell
210- PS C:\ > Get-PSSession -ComputerName Server02
209+ PS> Get-PSSession -ComputerName Server02
211210
212211Id Name ComputerName State ConfigurationName Availability
213212-- ---- ------------ ----- ----------------- ------------
@@ -219,7 +218,7 @@ The following command connects to Session2. The PSSession is now open and
219218available.
220219
221220``` powershell
222- PS C:\ > Connect-PSSession -ComputerName Server02 -Name Session2
221+ PS> Connect-PSSession -ComputerName Server02 -Name Session2
223222
224223Id Name ComputerName State ConfigurationName Availability
225224-- ---- ------------ ----- ----------------- ------------
@@ -250,7 +249,7 @@ command that ran in the Session3 session. The command uses the **OutTarget**
250249parameter to get the results in a job.
251250
252251``` powershell
253- PS C:\ > Receive-PSSession -ComputerName Server02 -Name Session3 `
252+ PS> Receive-PSSession -ComputerName Server02 -Name Session3 `
254253 -OutTarget Job
255254
256255Id Name PSJobTypeName State HasMoreData Location
@@ -261,7 +260,7 @@ Id Name PSJobTypeName State HasMoreData Location
261260To get the results of the job, use the ` Receive-Job ` cmdlet.
262261
263262``` powershell
264- PS C:\ > Get-Job | Receive-Job -Keep
263+ PS> Get-Job | Receive-Job -Keep
265264
266265ProviderName: PowerShell
267266
@@ -299,43 +298,41 @@ reconnected.
299298
300299``` powershell
301300# Session 1
302- PS C:\ > New-PSSession -ComputerName Server30 -Name Test
301+ PS> New-PSSession -ComputerName Server30 -Name Test
303302
304303Id Name ComputerName State ConfigurationName Availability
305304-- ---- ------------ ----- ----------------- ------------
3063051 Test Server30 Opened Microsoft.PowerShell Available
307306
308307# Session 2
309- PS C:\ > Get-PSSession -ComputerName Server30 -Name Test
308+ PS> Get-PSSession -ComputerName Server30 -Name Test
310309
311310Id Name ComputerName State ConfigurationName Availability
312311-- ---- ------------ ----- ----------------- ------------
3133121 Test Server30 Disconnected Microsoft.PowerShell Busy
314313
315314# Session 1
316- PS C:\ > Get-PSSession -ComputerName Server30 -Name Test |
315+ PS> Get-PSSession -ComputerName Server30 -Name Test |
317316>> Disconnect-PSSession
318317
319318Id Name ComputerName State ConfigurationName Availability
320319-- ---- ------------ ----- ----------------- ------------
3213201 Test Server30 Disconnected Microsoft.PowerShell None
322321
323322# Session 2
324- PS C:\ > Get-PSSession -ComputerName Server30
323+ PS> Get-PSSession -ComputerName Server30
325324
326325Id Name ComputerName State ConfigurationName Availability
327326-- ---- ------------ ----- ----------------- ------------
3283271 Test Server30 Disconnected Microsoft.PowerShell None
329328
330329# Session 2
331- PS C:\ > Connect-PSSession -ComputerName Server01 -Name Test
330+ PS> Connect-PSSession -ComputerName Server01 -Name Test
332331
333332Id Name ComputerName State ConfigurationName Availability
334333-- ---- ------------ ----- ----------------- ------------
335- 3 Test Server30 Opened Microsoft.PowerShell Available
336-
337- # Session 1
338- PS C:\> Get-PSSession -ComputerName Server30
334+ 3 Test Server30 Opened Microsoft.PowerShell Available# Session 1
335+ PS> Get-PSSession -ComputerName Server30
339336
340337Id Name ComputerName State ConfigurationName Availability
341338-- ---- ------------ ----- ----------------- ------------
@@ -398,7 +395,7 @@ in SessionOption object and the IdleTimeout value in the $PSSessionOption
398395preference variable do not change the value of the IdleTimeout of the
399396PSSession in a ` Connect-PSSession ` or ` Receive-PSSession ` command.
400397
401- * To create a PSSession with a particular idle timeout value, create
398+ - To create a PSSession with a particular idle timeout value, create
402399 a $PSSessionOption preference variable. Set the value of the
403400 IdleTimeout property to the desired value (in milliseconds).
404401
@@ -411,7 +408,7 @@ PSSession in a `Connect-PSSession` or `Receive-PSSession` command.
411408$PSSessionOption = New-PSSessionOption -IdleTimeoutMSec 172800000
412409```
413410
414- * To create a PSSession with a particular idle timeout value, use
411+ - To create a PSSession with a particular idle timeout value, use
415412 the ** IdleTimeoutMSec** parameter of the ` New-PSSessionOption ` cmdlet.
416413 Then, use the session option in the value of the ** SessionOption**
417414 parameter of the ` New-PSSession ` or ` Invoke-Command ` cmdlets.
@@ -427,7 +424,7 @@ $o = New-PSSessionOption -IdleTimeoutMSec 172800000
427424New-PSSession -SessionOption $o
428425```
429426
430- * To change a the idle timeout of a PSSession when disconnecting,
427+ - To change a the idle timeout of a PSSession when disconnecting,
431428 use the ** IdleTimeoutSec** parameter of the ` Disconnect-PSSession `
432429 cmdlet.
433430
@@ -437,7 +434,7 @@ New-PSSession -SessionOption $o
437434Disconnect-PSSession -IdleTimeoutSec 172800
438435```
439436
440- * To create a session configuration with a particular idle timeout
437+ - To create a session configuration with a particular idle timeout
441438 and maximum idle timeout, use the ** IdleTimeoutSec** and ** MaxIdleTimeoutSec**
442439 parameters of the ` New-PSTransportOption ` cmdlet. Then, use the
443440 transport option in the value of the ** TransportOption** parameter
@@ -450,7 +447,7 @@ $o = New-PSTransportOption -IdleTimeoutSec 172800 -MaxIdleTimeoutSec 259200
450447Register-PSSessionConfiguration -Name Test -TransportOption $o
451448```
452449
453- * To change the default idle timeout and maximum idle timeout of
450+ - To change the default idle timeout and maximum idle timeout of
454451 a session configuration, use the ** IdleTimeoutSec** and ** MaxIdleTimeoutSec**
455452 parameters of the ` New-PSTransportOption ` cmdlet. Then, use the
456453 transport option in the value of the ** TransportOption** parameter
@@ -473,12 +470,12 @@ whether the command continues to run while the session is disconnected.
473470
474471Valid values:
475472
476- * Block
473+ - Block
477474
478475 When the output buffer is full, execution is suspended until the buffer is
479476 clear.
480477
481- * Drop
478+ - Drop
482479
483480 When the output buffer is full, execution continues. As new output is
484481 generated, the oldest output is discarded.
@@ -513,7 +510,7 @@ If you are a member of the Administrators group on the remote computer, you
513510can also create and change the output buffering mode of session
514511configurations.
515512
516- * To create a PSSession with an output buffering mode of Drop, create
513+ - To create a PSSession with an output buffering mode of Drop, create
517514 a $PSSessionOption preference variable in which the value of the
518515 OutputBufferingMode property is Drop.
519516
@@ -526,7 +523,7 @@ configurations.
526523$PSSessionOption = New-PSSessionOption -OutputBufferingMode Drop
527524```
528525
529- * To create a PSSession with an output buffering mode of Drop, use
526+ - To create a PSSession with an output buffering mode of Drop, use
530527 the ** OutputBufferingMode** parameter of the ` New-PSSessionOption `
531528 cmdlet to create a session option with a value of Drop. Then, use
532529 the session option in the value of the ** SessionOption** parameter of
@@ -543,7 +540,7 @@ $o = New-PSSessionOption -OutputBufferingMode Drop
543540New-PSSession -SessionOption $o
544541```
545542
546- * To change a the output buffering mode of a PSSession when
543+ - To change a the output buffering mode of a PSSession when
547544 disconnecting, use the ** OutputBufferingMode** parameter of the
548545 ` Disconnect-PSSession ` cmdlet.
549546
@@ -553,7 +550,7 @@ New-PSSession -SessionOption $o
553550Disconnect-PSSession -OutputBufferingMode Drop
554551```
555552
556- * To change a the output buffering mode of a PSSession when
553+ - To change a the output buffering mode of a PSSession when
557554 reconnecting, use the ** OutputBufferingMode** parameter of the
558555 ` New-PSSessionOption ` cmdlet to create a session option with
559556 a value of Drop. Then, use the session option in the value of the
@@ -563,10 +560,10 @@ Disconnect-PSSession -OutputBufferingMode Drop
563560
564561``` powershell
565562$o = New-PSSessionOption -OutputBufferingMode Drop
566- Connect-PSSession -Cn Server01 -Name Test -SessionOption $o
563+ Connect-PSSession -ComputerName Server01 -Name Test -SessionOption $o
567564```
568565
569- * To create a session configuration with a default output buffering
566+ - To create a session configuration with a default output buffering
570567 mode of Drop, use the ** OutputBufferingMode** parameter of the
571568 ` New-PSTransportOption ` cmdlet to create a transport option object
572569 with a value of Drop. Then, use the transport option in the value of
@@ -579,7 +576,7 @@ $o = New-PSTransportOption -OutputBufferingMode Drop
579576Register-PSSessionConfiguration -Name Test -TransportOption $o
580577```
581578
582- * To change the default output buffering mode of a session
579+ - To change the default output buffering mode of a session
583580 configuration, use the ** OutputBufferingMode** parameter of the
584581 ` New-PSTransportOption ` cmdlet to create a transport option with a
585582 value of Drop. Then, use the Transport option in the value of the
0 commit comments