Connecting PowerShell to

The ODBC Driver enables you to work with data in Windows PowerShell. Note that the procedure outlined in this blog is the same for any ODBC driver, so it's still relevant even if you are using PowerShell with another ODBC driver.

The ODBC Driver is available to download from the Easysoft web site:

  1. Download the Windows ODBC Driver. (Registration required.)
  2. Install and license the ODBC Driver on the machine where is installed.

    For installation instructions, see the ODBC Driver documentation.

Before you can use the ODBC Driver to connect PowerShell to, you need to configure an ODBC data source. An ODBC data source stores the connection details for the target database (e.g. and the ODBC driver that is required to connect to it (e.g. the ODBC driver).

To create a ODBC Driver data source:

  1. In ODBC Administrator, choose the System DSN tab, and then choose Add.
  2. In the Create New Data Source dialog box, choose Easysoft ODBC-Salesforce Driver, and then choose Finish.
  3. Complete the Easysoft ODBC-Salesforce Driver DSN Setup dialog box:
    Setting Value
    User Name The name of your user. For example,
    Password The password for your user.
    Token The security token for your user, if required.

    To find out whether you need to supply a security token, choose the Test button. If the connection attempt fails with an error which contains LOGIN_MUST_USE_SECURITY_TOKEN, you need to supply one. emails the security token to the email address associated with your user account. If you have not received a security token, you can regenerate it. will then email the new security token to you. To regenerate your security token, log in to and then choose Setup from the user menu. Search for "security token" in the Quick Find box. Click Reset Security Token in the Reset Security Token page. When you receive the token in your email client, copy it and then paste it into the Token field.

  4. Use the Test button to verify that you can successfully connect to

In a PowerShell window, enter this code to retrieve some ODBC data:

PS C:\> $connectionstring = 'DSN=MyODBCDataSource'
PS C:\> $sql = 'select top 1 * from account'
PS C:\> $connection = New-Object System.Data.Odbc.OdbcConnection($connectionstring)
PS C:\> $
PS C:\> $command = New-Object system.Data.Odbc.OdbcCommand($sql,$connection)
PS C:\> $adapter = New-Object system.Data.Odbc.OdbcDataAdapter($command)
PS C:\> $table = New-Object system.Data.datatable
PS C:\> $adapter.fill($table)
PS C:\> $connection.close()
PS C:\> $table
Id                   : 001i000000AOq3NAAT
IsDeleted            : 0
MasterRecordId       :
Name                 : United Oil & Gas Corp.
Type                 : Customer - Direct
ParentId             :
BillingStreet        : 1301 Avenue of the Americas
                       New York, NY 10019
BillingCity          : New York
BillingState         : NY
BillingPostalCode    :
BillingCountry       : United States
BillingStateCode     : NY
BillingCountryCode   : US
BillingLatitude      :