Skip to content

Get-Connection

DBSystems: Lists active SimplySQL database connections

#Requires -Version 5.0
#Requires -Modules SimplySQL

[CmdLetBinding()]
Param(
    [switch]$ShowAll,
    [string]$ConnectionName = "DefaultConnection"
)

Import-Module SimplySQL

try {
    if ($ShowAll) {
        $result = Get-SqlConnection -All -ErrorAction Stop
    } else {
        $result = Get-SqlConnection -ConnectionName $ConnectionName -ErrorAction Stop
    }
    
    Write-Output $result
} catch {
    throw
}
Off

If set, returns all active SQL connections

Specifies the name of the connection to retrieve (Defaults to 'DefaultConnection')

An interactive directory of PowerShell scripts.