Ready to get started?

Connect to live data from Harvest with the API Driver

Connect to Harvest

Pipe Harvest Data to CSV in PowerShell



Use standard PowerShell cmdlets to access Harvest tables.

The CData Cmdlets Module for Harvest is a standard PowerShell module offering straightforward integration with Harvest. Below, you will find examples of using our API Cmdlets with native PowerShell cmdlets.

Creating a Connection to Your Harvest Data

Start by setting the Profile connection property to the location of the Harvest Profile on disk (e.g. C:\profiles\Harvest.apip). Next, set the ProfileSettings connection property to the connection string for Harvest (see below).

Harvest API Profile Settings

To authenticate to Harvest, you can use either Token authentication or the OAuth standard. Use Basic authentication to connect to your own data. Use OAuth to allow other users to connect to their data.

Using Token Authentication

To use Token Authentication, set the APIKey to your Harvest Personal Access Token in the ProfileSettings connection property. In addition to APIKey, set your AccountId in ProfileSettings to connect.

Using OAuth Authentication

First, register an OAuth2 application with Harvest. The application can be created from the "Developers" section of Harvest ID.

After setting the following connection properties, you are ready to connect:

  • ProfileSettings: Set your AccountId in ProfileSettings.
  • AuthScheme: Set this to OAuth.
  • OAuthClientId: Set this to the client ID that you specified in your app settings.
  • OAuthClientSecret: Set this to the client secret that you specified in your app settings.
  • CallbackURL: Set this to the Redirect URI that you specified in your app settings.
  • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to manage how the driver obtains and refreshes the OAuthAccessToken.

$conn = Connect-API  -Profile "$Profile" -ProfileSettings "$ProfileSettings" -AccountId "$AccountId"

Selecting Data

Follow the steps below to retrieve data from the Invoices table and pipe the result into to a CSV file:

Select-API -Connection $conn -Table Invoices | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myInvoicesData.csv -NoTypeInformation

You will notice that we piped the results from Select-API into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.

The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.