commands

^

Disconnect-DbaInstance

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Disconnect-DbaInstance on GitHub.
Want to see the Bill Of Health for this command? Check out Disconnect-DbaInstance.

Synopsis

Disconnects or closes a connection to a SQL Server instance

Description

Disconnects or closes a connection to a SQL Server instance

To clear all of your connection pools, use Clear-DbaConnectionPool

Syntax

Disconnect-DbaInstance
    [[-InputObject] <PSObject[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaConnectedInstance | Disconnect-DbaInstance

Disconnects all connected instances

Example: 2
PS C:\> Get-DbaConnectedInstance | Out-GridView -Passthru | Disconnect-DbaInstance

Disconnects selected SQL Server instances

Example: 3
PS C:\> $server = Connect-DbaInstance -SqlInstance sql01
PS C:\> $server | Disconnect-DbaInstance

Disconnects the $server connection

Optional Parameters

-InputObject

The server object to disconnect from, usually piped in from Get-DbaConnectedInstance

Alias
Required False
Pipeline true (ByValue)
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value