Oracle goes there ==> …/oracle-odbc-hello-world-with-powershell.html
To test Sybase ODBC driver with Powershell, it’s not much different
- configure the DsN with odbcconf or %SYSTEMROOT%\SysWOW64\odbcconf for the 32bits drivers under Windows 64.
- test it, same as in Oracle. If you need to test the 32bits drivers under 64bits windows, use the 32bits powershell %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe
cmd /c "%SYSTEMROOT%\SysWOW64\odbcconf.exe /a {configdsn ""Adaptive Server Enterprise"" ""DSN=helloworld|database=mydb|port=25000|server=srv01""}"
The name of the driver is important. It is probably also called “Adaptive Server Enterprise” on your machine.
$conn = New-Object data.odbc.odbcconnection
$conn.ConnectionString = "dsn=helloworld;uid=scott;pwd=tiger"
$conn.Open()
(new-Object Data.Odbc.OdbcCommand("select 'Hello World'",$conn)).ExecuteScalar()
$conn.close()
Note: odbcconf will be removed in future release, prefer Add-OdbcDsn