Skip to content

Instantly share code, notes, and snippets.

@fusspawn
Created July 30, 2020 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fusspawn/22a1157f13d2658f5b34f70d400567c6 to your computer and use it in GitHub Desktop.
Save fusspawn/22a1157f13d2658f5b34f70d400567c6 to your computer and use it in GitHub Desktop.
Function Test-ODBCConnection {
[CmdletBinding()]
param(
[Parameter(Mandatory=$True,
HelpMessage="DSN name of ODBC connection")]
[string]$DSN
)
$conn = new-object system.data.odbc.odbcconnection
$conn.connectionstring = "(DSN=$DSN)"
try {
if (($conn.open()) -eq $true) {
$conn.Close()
$true
}
else {
$false
}
} catch {
Write-Host $_.Exception.Message
$false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment