Using PowerShell to add an ODBC Data Source

As an alternative to using the ODBC Data Source Administrator to add a Sage 50 ODBC data source it is possible to use a PowerShell script to achieve the same effect. However, this method is best left to IT Staff who are familiar with PowerShell.

The first requirement is that the Sage ODBC Driver has already been installed.  It is also likely that the Powershell script must be run as an administrator.

The script to remove an ODBC data source called 'AcademySage' takes the form:

Remove-OdbcDsn -Name "AcademySage" -DsnType "System" -Platform "32-bit"

And the script to add a new ODBC data source called 'AcademySage'

Add-OdbcDsn -Name "AcademySage" -DriverName "Sage Line 50 v25" -DsnType "System" -Platform "32-bit" -SetPropertyValue "DataPathname=\\ServerName\Sage\Company.000\ACCDATA"

 Where the version of Sage is v25 and the path to the Sage data is \\ServerName\Sage\Company.000\ACCDATA.

This method would be particularly useful where a number of Sage companies are being used.