Created
July 30, 2020 14:23
-
-
Save fusspawn/22a1157f13d2658f5b34f70d400567c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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