Close the SqlConnection.


Close-SqlConnection [[-ConnectionName] <String>] [<CommonParameters>]


Closes the connection and disposes of the underlying object. This will also rollback the current transaction if there is one.


-ConnectionName <String>

User defined name for connection.

Required? False
Position? 0
Default value Default
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? False


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (


Example 1

PS C:\> Close-SqlConnection

Closes the default connection (same as Close-SqlConnection "Default").

Example 2

PS C:\> Close-SqlConnection -ConnectionName Test

Closes the SqlConnection named "Test".

Last edited Jun 20, 2015 at 4:44 PM by mastertook, version 2