commands

^

Get-DbaConnectedInstance

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

 

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

Synopsis

Returns SQL Server instances currently cached in the dbatools connection pool

Description

Shows all SQL Server connections that are currently active or cached in your PowerShell session. When you connect to instances using dbatools commands like Connect-DbaInstance, those connections are stored in an internal cache for reuse. This command reveals what's in that cache, including connection details like whether pooling is enabled and the connection type (SMO server objects vs raw SqlConnection objects). Use this to track active connections before cleaning them up with Disconnect-DbaInstance or to troubleshoot connection-related issues in long-running scripts.

Syntax

Get-DbaConnectedInstance
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaConnectedInstance

Gets all connected SQL Server instances

Example: 2
PS C:\> Get-DbaConnectedInstance | Select *

Gets all connected SQL Server instances and shows the associated connectionstrings as well