PowerShell Disconnect-PSSession Cmdlet

PowerShell Disconnect-PSSession Cmdlet

PowerShell Disconnect-PSSession Cmdlet

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed Exit-PSSession cmdlet in PowerShell.

https://cloudaffaire.com/powershell-exit-pssession-cmdlet/

In this blog post, we will discuss Disconnect-PSSession cmdlet in PowerShell. You can use Disconnect-PSSession cmdlet to disconnect a PSSession from a local or remote computer. Using Disconnect-PSSession cmdlet, you can only disconnect open PSSessions that are connected to the current session. Disconnect-PSSession cmdlet cannot be used to disconnect a broken or closed PSSession. When you disconnect an open PSSession, the commands that are still executing on that session will continue to execute till the session timeout period reached, only new command will not run on the disconnected session. You can connect to a disconnected session using Connect-PSSession cmdlet.

Disconnect-PSSession Cmdlet Syntax:

Disconnect-PSSession Cmdlet Argument List:

  • Confirm: Prompts you for confirmation before running the cmdlet.
  • Id: Disconnects from sessions with the specified session ID. Type one or more IDs (separated by commas), or use the range operator (..) to specify a range of IDs.
  • IdleTimeoutSec: Changes the idle timeout value of the disconnected PSSession. Enter a value in seconds. The minimum value is 60 (1 minute).
  • InstanceId: Disconnects from sessions with the specified instance IDs.
  • Name: Disconnects from sessions with the specified friendly names. Wildcards are permitted.
  • OutputBufferingMode: Determines how the command output is managed in the disconnected session when the output buffer is full. The default value is Block. Valid values are:
    • Block: When the output buffer is full, execution is suspended until the buffer is clear.
    • Drop: When the output buffer is full, execution continues. As a new output is saved, the oldest output is discarded.
    • None: No output buffering mode is specified.
  • Session: Disconnects from the specified PSSessions. Enter PSSession objects, such as those that the New-PSSession cmdlet returns. You can also pipe a PSSession object to Disconnect-PSSession.
  • ThrottleLimit: Sets the throttle limit for the Disconnect-PSSession command. The throttle limit is the maximum number of concurrent connections that can be established to run this command. If you omit this parameter or enter a value of 0, the default value, 32, is used.
  • WhatIf: Shows what would happen if the cmdlet runs. The cmdlet is not run.

PowerShell Disconnect-PSSession Cmdlet:

Hope you have enjoyed this article. In the next blog post, we will discuss Connect-PSSession CmdLet in PowerShell.

To get more details on PowerShell, kindly follow below official documentation

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about?view=powershell-5.1

 

Leave a Reply

Close Menu